Android: What care should I take when using a View's setTag() property?
android, view
Solution
One of the most popular uses of the `setTag(Object)` method is exactly keeping a reference to a class instance - if you have used custom `ListView` and custom `Adapter`, you should know about the ViewHolder pattern.
Without knowing much about your particular problem, I would say - Is this dangerous sometimes? Yes, if used irresponsibly. Does this mean you should avoid it at any cost? No, absolutely not.
Edit: Why do you want to have the parsed data for your views bound to them?
Do you really need it, or you can populate some type of a model? If you want to access the tag of a view in a context, where your view doesn't carry the same meaning/position (like the `convertView` does in our favorite ViewHolder example :)), I would think using tags is OK.
Otherwise, I'm sure that if you give it a little more thought, you'll find another approach better suited for your problem.
Problem
Because Java uses object references and not objects themselves, what prevents me from using setTag() to tag a view with an entire object instead of an object's property? Is it just the attribute lookup time when trying to resolve one of the attributes after the getTag() call or is there any other specific thing I should be concerned about? As for my specific problem, I am using a custom listview that has an imageview and a textview. Initially I bind the listview to a custom adapter to fetch some xml data and then use certain tags inside each item's xml to populate my listview. So the "entire object" I was referring to was the parsed version of the entire XML of an item...