Skip to content Skip to sidebar Skip to footer

Trying To Get Drawable Resource Id From Its Name In Android

I have a resource file like this: strings.xml My Category 01My Category 02

Solution 1:

One simple solution would be to parse the string and get only the image name as below.

String[] Image1 = array[1][1].split("/");
Strings= Image1[Image1.length-1].replace(".png","").trim();

intresID=this.context.getResources().getIdentifier(s , "drawable", this.context.getPackageName());

Solution 2:

Post a Comment for "Trying To Get Drawable Resource Id From Its Name In Android"