Reputation: 14305
I have this type of image path
String img_path = "R.drawable."+lower+"_25";
lower contain dynamic name of images...
this images are already in drawable how to show images in my
ImageView in android
Upvotes: 2
Views: 1366
Reputation: 12685
Make constructor in your adapter
public class MyAdapter extends XXXXXXX{
Context con;
public MyAdapter(Context con) {
this.con = con;
}
.
.
.
int id = con.getResources().getIdentifier(lower+"_25", "drawable", "<your package name>");
imageView.setBackgroundResource(image_id);
}
Upvotes: 2
Reputation: 128428
You can use:
getResources().getIdentifier(lower+"_25", "drawable", getPackageName())
Upvotes: 1
Reputation: 15973
You can get the id of the image in the drawable using it's name, using:
int image_id = getResources().getIdentifier(lower+"_25", "drawable", getPackageName());
imageView.setBackgroundResource(image_id);
Upvotes: 1