private ImageView imge;
imge=(ImageView) findViewById(R.id.img); //image
String Img_Name = Image_name dynamically;
try {
int id = R.drawable.class.getField(Img_Name).getInt(null);
imge.setImageResource( id );
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imge=(ImageView) findViewById(R.id.img); //image
String Img_Name = Image_name dynamically;
try {
int id = R.drawable.class.getField(Img_Name).getInt(null);
imge.setImageResource( id );
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
No comments :
Post a Comment