SageCoder SageCoder -5 years ago 126
Android Question

Get the name of the image resource used in image button

I'm new to Android programming and I want to know that how can I get the name of the image resource that is currently set on the image button.
eg : b1.setImageResource(R.drawable.img);
//where b1 is the image button and img is the name of the png file present in res/drawable.

Now I would like to know how would I get the name of the image file i.e "img".
Thanks in advance.

Answer Source

You can use setTag() and getTag() this way you can store any data you want.

String imageName = (String) imageView.getTag();

Let me know! ;)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download