UMAR-MOBITSOLUTIONS
UMAR-MOBITSOLUTIONS

Reputation: 77984

How to get Image name in java?

i want to get image name in android

for example,

ImageView img = (ImageView)findViewByID(R.id.MyImage);

img.srcName() // it should return following android:src="@drawable/abc"

is it possible or not? any help would be appreciated.

Upvotes: 4

Views: 2964

Answers (3)

ᏗᎷᏒᎧシ
ᏗᎷᏒᎧシ

Reputation: 8

Try getResourcesEntryName() method

getResources().getResourceEntryName(0x000000);

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006624

is it possible or not?

It is not possible. For starters, there may not be a resource involved in the ImageView, as images can come from many places.

Upvotes: 1

Raz
Raz

Reputation: 9058

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

getResources().getResourceName(resid);

But you need the resId for that. Check the Resources.

Upvotes: 3

Related Questions