Skip to content

Commit

Permalink
deselect all tags when click on an unselected tag
Browse files Browse the repository at this point in the history
  • Loading branch information
anhtuan23 committed Jun 12, 2018
1 parent 7c81776 commit c3bc26e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sample/src/main/java/co/lujun/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ public void onTagCrossClick(int position) {
mTagContainerLayout3.setOnTagClickListener(new TagView.OnTagClickListener() {
@Override
public void onTagClick(int position, String text) {
List<Integer> selectedPositions = mTagContainerLayout3.getSelectedTagViewPositions();
//deselect all tags when click on an unselected tag. Otherwise show toast.
if (selectedPositions.isEmpty() || selectedPositions.contains(position)){
Toast.makeText(MainActivity.this, "click-position:" + position + ", text:" + text,
Toast.LENGTH_SHORT).show();
} else {
//deselect all tags
for (int i : selectedPositions){
mTagContainerLayout3.deselectTagView(i);
}
}

}

@Override
Expand Down

0 comments on commit c3bc26e

Please sign in to comment.