Skip to content

Commit

Permalink
Merge pull request #2 from shaishavgandhi05/features
Browse files Browse the repository at this point in the history
Added feature to make EditTag non-editable
  • Loading branch information
qiugang committed Jul 8, 2016
2 parents 33b32d2 + 393af56 commit c97c4cd
Showing 1 changed file with 15 additions and 4 deletions.
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();
}
}

0 comments on commit c97c4cd

Please sign in to comment.