I cant load an image from @drawable to ImageView using String as name of the image.
Here's my code;
String uri = "@drawable/"+imgname; // image file
int resID = getResources().getIdentifier(uri , "drawable", getPackageName());
Drawable drawable = getResources().getDrawable(resID); //<----line with error
ImageView imageview= (ImageView)findViewById(R.id.hardImg);
imageview.setImageDrawable(drawable);
error log:
android.content.res.Resources$NotFoundException: Resource ID #0x0
"@drawable/". You just need the resource name, which is the filename, without the extension.