Question

I'm trying to set a tag for a textView in android, but I cant seem to figure out how to set the tag, I tried using the following code, and it didn't have any errors but then I cant figure out how to use findViewByTag to do something with the textView later, any help would be appreciated!

playerCounter.setTag("playercounter"+counter);
Was it helpful?

Solution

I don't know of any built-in findViewByTag() function, are you confusing it with findViewById()?

Unlike IDs, tags are not used to identify views. Tags are essentially an extra piece of information that can be associated with a view. They are most often used as a convenience to store data related to views in the views themselves rather than by putting them in a separate structure.

From the Developer Documentation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top