Yes, I know you need a unique resource id when calling the version of these functions that requires a key, but I cannot for the life of me figure out how to create a resource id that can be used in this way. A final variable in my class wont work and neither will a hard coded value. Both threw an IllegalArgumentException. So what gives, how do you use these methods?
Spara
From the Javadoc:
So you can’t just make up values and place them in a local variable.
Every resource you create whether it’s a string (
R.string.*), or a layout (R.layout.*) or an individualView(R.id.*) can have an ID. This is something you must be doing already.If you do need to store multiple objects against a single
View, then you need to use theR.idvariant as a key, likesomeView.setKey(R.id.my_key_1, someObject).