ssk
ssk

Reputation: 77

How to get image name from resourceid in android?

int igotit = getResources().getIdentifier(val, "drawable", getPackageName());

i got resourceid from that how to display imagename?

Upvotes: 6

Views: 3218

Answers (2)

Houcine
Houcine

Reputation: 24181

use this :

String imageName = getResources().getResourceName(R.id.img);

refer doc . there is also the method : getResourceEntryName(int)

Upvotes: 7

Nermeen
Nermeen

Reputation: 15973

To use the method

getResources().getIdentifier(val, "drawable", getPackageName()); 

the val is the image name

check here

Upvotes: 1

Related Questions