I am storing my project related images in drawable folder. Also I am storing the image names in string variable and dynamically I am trying to set those images to the imageview. But the image is not displaying. Please help me in this regard.
My Code:
int res = getResources().getIdentifier(imagename, "drawable", this.getPackageName());
imageview= (ImageView)findViewById(R.id.imageView);
imageview.setImageResource(res);
In the above code "imagename" is the string variable which contains the image name.
Thanks in advance
This works for me (dont use the extension of the image, just the name):
getDrawable()
is deprecated, so try this