To make things simple: I got the drawable name from a JSON file and is now in a variable, how can I assign the correct drawable to an ImageView
with the name as a String
? We can assume that the drawable with that name always exists.
String image_name = "image1.png";
ImageView imageView = (ImageView)view.findViewById(R.id.myImageView);
imageView.setImageResource(image_name); // FAIL since is expecting the drawable and not the name as a String.