I know that changing the ImageView resource is not big deal just using myImageView.setImageResource(mynewImageDrawable)
but what I want to do is to check the current ImageSource before changing it.
basically, I want to implement my own group radio buttons using imageViews. so every time any imageView is clicked, the oncliked event method will change the Image Resources of my group.
and sorry for my poor English.
regards,
redsea
There is no
getDrawableIdfunction so you’ll need to do something like set a tag for theImageViewwhen you change its drawable. For instance, set the drawable id as a tag for theImageViewso you could just get the drawable id from the tag.How to do that?
I’d say 90% of the time, your views wont have any tag on them, so the easiest way is to assume your tag is the only tag:
What if I already have a tag on my view
Android views can host multiple tags at the same time, as long as they have a unique identifier. You’d need to create a unique id resource and add it as the first argument to the
setTagmethod call. Leaving the code like this: