How To Convert R.drawable String To R.drawable Integer Format In Android?
I would like to R.drawable which is in a dynamic string format currently to an integer format.How can be it done.Please guide me with a snippet on this to resolve it.Thank you. Int
Solution 1:
You can use this
StringmDrawableName="myimg";
intresID= getResources().getIdentifier(mDrawableName , "drawable", getPackageName());
or
StringimageName="picture";
intresID= getResources().getIdentifier(imageName, "drawable", "package.name");
ImageView image;
image.setImageResource(resID);
Post a Comment for "How To Convert R.drawable String To R.drawable Integer Format In Android?"