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!
 

更多相关文章

  1. android 我的功能模块模板布局之一
  2. react-native调用Android原生模块
  3. Android Studio : 导入项目出现 peer not authenticated 错误
  4. android 项目收获01
  5. Android 项目代码混淆
  6. android studio 3.6.1导入项目报错(无法下载classpath里的内容)
  7. Android studio升级3.0.1之后原项目签名打包出错
  8. android 编译模块
  9. Android Studio 关联项目软链接

随机推荐

  1. android升级数据库(Sqlite)简单示例
  2. Android(安卓)studio 开发一个用户登录界
  3. Android(安卓)AnalogClock and DigitalCl
  4. android 控件 NumberPicker 简单使用
  5. Android(安卓)SDcard 文件读写,RandomAcce
  6. Android(安卓)情景模式
  7. Android(安卓)来电状态监听
  8. Android获取手机配置信息
  9. android开机启动代码
  10. Vuforia How To Use Android(安卓)Plugin