一个view设置多个Tag

来源:互联网 发布:vb.net 注释快捷键 编辑:程序博客网 时间:2024/06/18 11:24
如果只需要设置一个tag,那么直接调用setTag(Object tag)方法就可以轻松搞定,如果一定需要使用多个tag绑定,那么需要先在res/values/ids.xml中添加

<resources>
    <item type="id" name="tag_first"></item>
    <item type="id" name="tag_second"></item>
</resources>

使用的时候写成
imageView.setTag(R.id.tag_first, "Hello");imageView.setTag(R.id.tag_second, "Success");
获得的时候:
imageView.getTag(R.id.tag_first);
就可以了
0 0
原创粉丝点击