//参数1:资源名称 参数3:类型("drawable"或"string")
public static int getResource(String imageName, Context context, String type) {
int resId = context.getResources().getIdentifier(imageName, type,
context.getPackageName());
return resId;
}
转载于:https://my.oschina.net/meetthebetteryour/blog/607843