I’m creating a custom View to be included in a class library. I need to add multiple tags to subviews that I am creating dynamically (in code, not xml), so this requires that I add use: View.setTag(int key, Object tag).
The key needs to be an id defined in the project R file, but since all of my views are dynamically created and the code is going into a library for use in other projects, I don’t have a hardcoded resource id on hand to use. Is there any way to discover a couple of defined resource ids programatically, or to define some programatically? Or am I going about this all wrong?
Thanks
Keep in mind that you can add any object as a tag. If the data you’re adding to the view is dynamic, then the easiest thing to do would be to add a Hashtable to the View as the tag. Then add all the key/value pairs you want to that Hashtable. On the other end, (the code processing the tag), you can iterate over the values by casting the View’s tag back into a Hashtable, and iterating over Hashtable.keys().