Android - getIdentifier 始终返回 0(库 + 应用程序)

标签 android resources

我有一个使用 Android 库 (com.appocaliptic.quizknife.core) 的 Android 项目 (com.appocaliptic.quizknife.app)。

我想做的是获取图片的资源ID,即图书馆。图片的路径是:res/drawable-xhdpi/fr_200_133.png

但是,所有尝试都使用 getIdentifier 结果为 0。问题出在哪里?

resId = getResources().getIdentifier("fr_200_133", "drawable", "com.appocaliptic.quizknife.core");
resId = getResources().getIdentifier("com.appocaliptic.quizknife.core:drawable/"+"fr_200_133", null, null);
resId = getResources().getIdentifier("drawable/fr_200_133", null, "com.appocaliptic.quizknife.core");

已编辑:

啊,在R.java中有drawable和corresponding属性。

最佳答案

我遇到了同样的问题:"getIdentifier result 0" 我通过删除图像扩展名(*.jpg、*.jpeg、...等)以匹配名称来解决它在 R.java 文件中

关于Android - getIdentifier 始终返回 0(库 + 应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12394688/

相关文章:

android - 由 : android. view.InflateException: Binary XML file line #11: Error inflating class fragment 引起

android - 为什么android工具栏高度被削减了?

Java Android 比较字符串格式的时间

android - 在 Android 中使用 HTML5 流式传输

java - 如何从日期时间字符串中获取时区

javascript - 只有 Firefox 类型错误 : "NetworkError when attempting to fetch resource."

sharepoint - 在运行时更改语言资源

javascript - 如何在不中断CPU的情况下从JavaScript中连续读取文件?

android - Android 资源的 XML 注释可以自动复制到 R 中吗?

visual-studio-2010 - 在visual studio 2010中将带有资源文件的dll部署到sharepoint 2010