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 fine for me.
Try this:
getDrawable() is deprecated. now you can use
adding image pointer to array