Issue
I used to set a tag to a view using view.setTag(t1);
and then get the view using parent.findViewWithTag(t1);
which returned correctly.
I now need to set 2 different tags for my views and I am doing that using
view.setTag(R.id.tag1, t1);
view.setTag(R.id.tag2, t2);
Where tag1 and tag2 are ids declared in res/values/ids.xml
I am then trying to get the view with tag t1, but parent.findViewWithTag(t1);
returns null. I searched and there is no method findViewWithTag
or similar that would also accept the key of the tag.
Is there any way to achieve this? If there isn't could you point me to where it's stated in the android documentation?
In this specific case, I could use id
instead of one of the tags, but for situations where that is not possible, I would like to know if it can be achieved using tags.
Solution
findViewWithTag(tag)
returns the View with the default tag set by setTag(tag)
as compared using tag.equals(getTag())
.
Answered By - Diego Torres Milano
Answer Checked By - Katrina (JavaFixing Volunteer)