How to get Image Resource

MOHRE picture MOHRE · Oct 14, 2014 · Viewed 26.4k times · Source

How should I get current image resource of an imageButton? I need something like this:

imageButton.getImageResource(); 

Thanks a lot

Answer

dimsuz picture dimsuz · Oct 14, 2014

I think you can't, current API doesn't allow this. But if you really need this, you can do something like this:

imageButton.setImageResource(R.drawable.your_resource);
imageButton.setTag(R.drawable.your_resource);
//
// somewhere later...
//
Integer resource = (Integer)imageButton.getTag();