Android 引用com.android.internal
16lz
2021-01-23
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 我的功能模块模板布局之一
- react-native调用Android原生模块
- Android Studio : 导入项目出现 peer not authenticated 错误
- android 项目收获01
- Android 项目代码混淆
- android studio 3.6.1导入项目报错(无法下载classpath里的内容)
- Android studio升级3.0.1之后原项目签名打包出错
- android 编译模块
- Android Studio 关联项目软链接