How to get image name in java?

I want to get the image name in android

eg,

ImageView img = (ImageView)findViewByID(R.id.MyImage); img.srcName() // it should return following android:src="@drawable/abc" 

Is this possible or not? Any help would be appreciated.

+4
source share
2 answers

is it possible or not?

It's impossible. First, there cannot be a resource involved in ImageView , since images can come from many places.

+1
source

You can get the name of the resource using this function:

 getResources().getResourceName(resid); 

But for this you need a ResID. Check out Resources.

+3
source

All Articles