How to set multiple tags to a button?

后端 未结 4 1673
既然无缘
既然无缘 2021-02-07 07:12

I have 16 buttons and I tag them to pair some terms set to buttons and imported from sqlite database. So, I tag them like this:

// labelForButton and tagForButto         


        
4条回答
  •  不要未来只要你来
    2021-02-07 08:11

    try :

    button.setTag(R.id.resource_id1,obj1);
    button.setTag(R.id.resource_id2,obj2);
    button.setTag(R.id.resource_id3,obj3);
    

    and to get the tags, use

    v.getTag(R.id.resource_id1);
    v.getTag(R.id.resource_id2);
    v.getTag(R.id.resource_id3);
    

    but, this will return only objects. you need to typecast it.

提交回复
热议问题