gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 23:16:42 28 4
gpt4 key购买 nike

我有一个使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com