Skip to content

Rock610/TagSelectorView

Repository files navigation

TagSelectorView

TagSelectorView

A tag selector with animation

注意2.0与1.0并不兼容,2.0之前最后版本号为 1.2.2.3

download blog

be free to contact me by the blog above or email wang1ran@163.com

gif

#Setup

repositories {
   jcenter()
}

dependencies {
    compile 'com.rock.android:tagselector:xxx'//version code
}

#Usage

  • in xml
<com.rock.android.tagselector.views.TagSelectView
        android:id="@+id/tagSelectView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
  • in your activity
TagSelectView tagSelectView = (TagSelectView) findViewById(R.id.tagSelectView);

List<Tags> dataList = new ArrayList<>();

int count = 2;
List<DataBean> dataBeanList = new ArrayList<>();
for (int i = 0; i < count; i++) {
    dataBeanList.add(new MyDataBean("item A" + i));
}

dataList.add(new Tags().
                setDefaultTag(dataBeanList.get(0).name)
                .setTags(dataBeanList)
                .setChangeAfterClicked(true)
                .setSelectFirst(false);
tagSelectView.attach(dataList);

data source must extend the DataBean

  • to insert a data to any tab
ITagSelectorTabView tagSelectorView = tagSelectView.getTabView(0).getTagSelectorView();
tagSelectorView.getData().add(0, new MyDataBean("im new"));
tagSelectorView.refresh();
  • get the selected tag
tagSelectView.setOnTagSelectedListener(new TagSelectView.OnTagSelectedListener() {
            @Override
            public void onTagSelected(int selectorListPosition, int tabPosition) {
                DataBean dataBean = dataList.get(tabPosition).tags.get(selectorListPosition);
                MyDataBean d = (MyDataBean) dataBean;
                //do something like request the network

            }
        });

  • listening the tab
tagSelectView.setOnTagViewStatusChangedListener(new TagSelectView.OnTagViewStatusChangedListener() {
            @Override
            public void onOpened(ITagSelectorTabView openedView) {
              
            }

            @Override
            public void onClosed(ITagSelectorTabView closedView) {
              
            }
        });

#License https://www.gnu.org/licenses/licenses.html

About

TagSelectorView

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages