2019独角兽企业重金招聘Python工程师标准>>> public int getResource(String imageName){ Context ctx=getBaseContext(); int resId = getResources().getIdentifier(imageName, "drawable" , ctx.getPackageName()); return resId } 说明:imageName就是在drawable文件夹下的图片,没有后缀名 转载于:https://my.oschina.net/u/1013545/blog/180843