本文主要是介绍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 引用com.android.internal的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!