标签:android io ar os sp on bs as nbsp
通过反射来获取资源id
try{
String resName = "ic_launcher";
int resId = R.drawable.class.getDeclaredField(resName).getInt(R.drawable.class);
imageView.setImageResource(resId);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
标签:android io ar os sp on bs as nbsp
原文地址:http://www.cnblogs.com/rfheh/p/4124840.html