0

I am setting a tag on a textview using the following code

    TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText("New Item");
tv.setTag("1");

How can I read the tag value I have set for this?

user1197941
  • 179
  • 3
  • 16
  • 1
    Using `getTag` of course. Have you checked this question: http://stackoverflow.com/questions/5291726/what-is-the-main-purpose-of-settag-gettag-methods-of-view it explains tags nicely. – theomega Oct 27 '12 at 15:10

2 Answers2

1

You can set tag with key also, so that you can set multiple tags with one component

like

tv.setTag(R.id.textView1, "1");

while getting you can do like

tv.getTag(R.id.textView1);
Devangi Desai
  • 1,355
  • 12
  • 17
0

If theres setTag there should also be getTag, use:

tv.getTag();
n00b
  • 2,738
  • 2
  • 20
  • 31