img.setImageResource(R.drawable.a2);
img.setTag(R.drawable.a2);
imageview drawable id in android
5
3
|
|||||||||||||
|
11
|
I think if I understand correctly this is what you are doing.
Right? So that function getDrawableId() doesn't exist. You can't get a the id that a drawable was instantiated from because the id is just a reference to the location of data on the device on how to construct a drawable. Once the drawable is constructed it doesn't have a way to get back the resourceId that was used to create it. But you could make it work something like this:
|
||||||||||||||||||||
|
2
|
I answered something like this in another question already, but will change it just a little for this one. Unfortunately, there is no In onCreate():
Then, if you like, you can create a simple function to get the drawable id:
Too easy. |