Android - Add multiple tags to ImageView

瘦欲@ 提交于 2019-12-04 20:18:31

Instead of looking for multiple tags you can use a class MyTag as follows to tag more than one data to a view

public class MyTag
{
   int  int_Tag;
   String  string_Tag;
   MyClass  myclass_obj_Tag;


    public MyTag()
    {
      int_Tag=0;
      string_Tag=null;
      myclass_obj_Tag=null;
    }

    public MyTag(int i,String s,MyClass m)
    {
      int_Tag=i;
      string_Tag=s;
      myclass_obj_Tag=m;
    }


}

create an object of this class and assign values to variables in object

MyTag myTag=new MyTag(1,"string_tag",myClass_obj);
iv.setTag(myTag);

just give it a try,I have used this method,

You can add any object as a tag. If the data you're adding need more data, the simplest way would be to add a Hashtable as the tag. Then add all the key/value pairs you want to that Hashtable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!