Android 引用com.android.internal

https://www.cnblogs.com/zhou-guobao/p/5145714.html
参考:
https://stackoverflow.com/questions/3486819/how-to-resolve-the-error-com-android-internal-r-cannot-be-resolved-when-i-usin

自己写的apk项目需要使用frameworks/base/core/res/res/drawable/ic_text_dot.xml这个资源

ImageView imageView = (ImageView) findViewById(R.id.img);

imageView.setImageDrawable(getDrawable(com.android.internal.R.drawable.ic_text_dot));  //Fail!(自己写的apk项目会fail,但是模块编译没问题)
出现问题的原因:
You cannot access id‘s of com.android.internal.R at compile time, but you can access the defined internal resources at runtime and get the resource by name.

imageView.setImageResource(Resources.getSystem().getIdentifier("ic_text_dot", "drawable", "android")); //Successful!
 

你可能感兴趣的:(Android)