diff --git a/README.md b/README.md index d7f0228..0c1e336 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Add below dependency in your **build.gradle** file. ```groovy dependencies { - compile 'co.lujun:androidtagview:1.1.2' + compile 'co.lujun:androidtagview:1.1.3' } ``` @@ -183,7 +183,7 @@ mTagContainerLayout.addTag(String text); ```java mTagContainerLayout.addTag(String text, int position); ``` -* Remove TagView on particular position, require the position of the TagView +* Remove TagView on particular position, require the position of the TagView. ```java mTagContainerLayout.removeTag(int position); ``` @@ -191,6 +191,10 @@ mTagContainerLayout.removeTag(int position); ```java mTagContainerLayout.removeAllTags(); ``` +* Get a TagView in specified position. +```java +mTagContainerLayout.getTagView(int position); +``` * Set color for each TagView. ```java List colors = new ArrayList(); @@ -204,6 +208,9 @@ mTagcontainerLayout.setTags(tags, colors); ## Change logs +### 1.1.3(2017-5-17) +- Add ```getTagView(int position)``` method to get TagView in specified position. + ### 1.1.2(2017-5-16) - Fix bugs diff --git a/androidtagview/build.gradle b/androidtagview/build.gradle index f7210dc..dbbf3b1 100644 --- a/androidtagview/build.gradle +++ b/androidtagview/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 9 targetSdkVersion 25 - versionCode 112 - versionName "1.1.2" + versionCode 113 + versionName "1.1.3" } buildTypes { release { diff --git a/androidtagview/src/main/java/co/lujun/androidtagview/TagContainerLayout.java b/androidtagview/src/main/java/co/lujun/androidtagview/TagContainerLayout.java index 75dca9d..31c2870 100644 --- a/androidtagview/src/main/java/co/lujun/androidtagview/TagContainerLayout.java +++ b/androidtagview/src/main/java/co/lujun/androidtagview/TagContainerLayout.java @@ -35,7 +35,7 @@ public class TagContainerLayout extends ViewGroup { /** * The list to store the tags color info */ - private ArrayList mColorArrayList; + private List mColorArrayList; /** * Horizontal interval, default 5(dp) @@ -720,7 +720,7 @@ public void setTags(List tags) { * @param tags * @param colorArrayList */ - public void setTags(List tags, ArrayList colorArrayList) { + public void setTags(List tags, List colorArrayList) { mTags = tags; mColorArrayList = colorArrayList; onSetTag(); @@ -1385,11 +1385,24 @@ public boolean isTagSupportLettersRTL() { } /** - * Set whether the 'support letters show with RTL(like: Android to diordnA)' style is enabled + * Set whether the 'support letters show with RTL(like: Android to diordnA)' style is enabled. * * @param mTagSupportLettersRTL */ public void setTagSupportLettersRTL(boolean mTagSupportLettersRTL) { this.mTagSupportLettersRTL = mTagSupportLettersRTL; } + + /** + * Get TagView in specified position. + * + * @param position the position of the TagView + * @return + */ + public TagView getTagView(int position){ + if (position < 0 || position >= mChildViews.size()) { + throw new RuntimeException("Illegal position!"); + } + return (TagView) mChildViews.get(position); + } } diff --git a/sample/src/main/java/co/lujun/sample/MainActivity.java b/sample/src/main/java/co/lujun/sample/MainActivity.java index 28e004d..9028e45 100644 --- a/sample/src/main/java/co/lujun/sample/MainActivity.java +++ b/sample/src/main/java/co/lujun/sample/MainActivity.java @@ -134,7 +134,7 @@ public void onTagCrossClick(int position) { mTagContainerLayout3.setTags(list3); mTagContainerLayout4.setTags(list4); - ArrayList colors = new ArrayList(); + List colors = new ArrayList(); //int[]color = {backgroundColor, tagBorderColor, tagTextColor} int[] col1 = {Color.parseColor("#ff0000"), Color.parseColor("#000000"), Color.parseColor("#ffffff")}; int[] col2 = {Color.parseColor("#0000ff"), Color.parseColor("#000000"), Color.parseColor("#ffffff")}; @@ -142,7 +142,7 @@ public void onTagCrossClick(int position) { colors.add(col1); colors.add(col2); - mTagcontainerLayout5.setTags(list5,colors); + mTagcontainerLayout5.setTags(list5, colors); final EditText text = (EditText) findViewById(R.id.text_tag); Button btnAddTag = (Button) findViewById(R.id.btn_add_tag); btnAddTag.setOnClickListener(new View.OnClickListener() {