Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added feature to make EditTag non-editable #2

Merged
merged 1 commit into from Jul 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 15 additions & 4 deletions library/src/main/java/me/originqiu/library/EditTag.java
Expand Up @@ -72,17 +72,28 @@ public EditTag(Context context, AttributeSet attrs, int defStyleAttr) {
inputTagLayoutRes = mTypedArray.getResourceId(R.styleable.EditTag_input_layout,
R.layout.view_default_input_tag);
mTypedArray.recycle();

setupView();

}

private void setupView() {
mFlowLayout = new FlowLayout(getContext());
LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
mFlowLayout.setLayoutParams(layoutParams);

addView(mFlowLayout);
addTagView();
setupListener();

}


public void setEditable(boolean editable){
if(!editable && mFlowLayout.getChildCount()>0){
mFlowLayout.removeViewAt(mFlowLayout.getChildCount()-1);
}
}

private void setupListener() {
Expand Down Expand Up @@ -149,10 +160,9 @@ private void addTagView() {
}

private TextView createTag(ViewGroup parent, String s) {
TextView tagTv = (TextView) LayoutInflater.from(getContext())
.inflate(tagViewLayoutRes,
parent,
false);
TextView tagTv = (TextView) LayoutInflater.from(getContext()).inflate(tagViewLayoutRes,
parent,
false);
tagTv.setText(s);
return tagTv;
}
Expand All @@ -172,5 +182,6 @@ public List<String> getTagList() {
public void setTagList(List<String> mTagList) {
this.mTagList = mTagList;
addTagView();
setupListener();
}
}