How to set multiple tags to a button?

后端 未结 4 1623
既然无缘
既然无缘 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 07:58

    If you need to add multiple tag into one view then you have to define the id for every tag in strings.xml file like:

    
    
    

    After adding the key you can use these keys in java file like below:

    rowView.setTag(R.id.section,mSectionList.get(position));
    rowView.setTag(R.id.hide_show,"close");
    

    This will set the tag. At the time of getting tag you need to typecast the object which originally you set like:

    String mSection=(String)rowView.getTag(R.id.section);
    String isOpen=(String)rowView.getTag(R.id.hide_show);
    

提交回复
热议问题