Android标签云控件:TagCloudLinkView

jopen 10年前
可以完成添加、删除、选择操作的标签控件,可以自定样式(颜色等),可删除的标签末尾带有'×'符号。和Android-Cloud-TagView-Plus(见正文相关代码)类似。

1.layout in xml

TagCloudLinkView provides a change deletable / undeletable tag or change layout color, text size, text color.

    <com.ns.developer.tagview.widget.TagCloudLinkView          xmlns:app="http://schemas.android.com/apk/res-auto"          android:id="@+id/test"          android:layout_width="500px"          android:layout_height="match_parent"          android:padding="4dp"          android:background="#ffffff"          app:isDeletable="false"          app:tagLayoutColor="#ffff0000"          app:tagTextSize="8sp"          app:tagTextColor="#ff9acd32"          app:deletableTextSize="8sp"          app:deletableTextColor="#ff9acd32"/>

2.add tag object

Example at Activity code.

TagCloudLinkView view = (TagCloudLinkView) findViewById(R.id.xxx);  view.add(new Tag(1,"TAG TEXT 1"));  view.add(new Tag(1,"TAG TEXT 2"));  view.add(new Tag(1,"TAG TEXT 3"));  view.drawTags();

ex1. set text select listener

Example at Activity code.

view.setOnTagSelectListener(new TagCloudLinkView.OnTagSelectListener(){      @Override      public void onTagSelected(Tag tag, int i) {          // write something      }  });

ex2. set delete event listener

Example at Activity code.

view.setOnTagDeleteListener(new TagCloudLinkView.OnTagDeleteListener() {      @Override      public void onTagDeleted(Tag tag, int i) {          // write something      }  });

项目主页:http://www.open-open.com/lib/view/home/1425303729712