首先贴一下搜到的用法:
使用getIdentifier()方法可以方便的获各应用包下的指定资源ID。
主要有两种方法:(1)方式一
Resources resources = context.getResources();
int indentify = resources. getIdentifier( org.loveandroid.androidtest:drawable/icon", null, null);
if(indentify>0){
icon = resources.getDrawable(indentify);
}