嗨,我的适配器代码中出现了Resourcesnotfoundexception。

码:

   public class Bag_adapter extends ArrayAdapter<Data> implements Filterable {
   //in getview()
        {
         try {
                    int i = getContext().getResources()
                            .getIdentifier(name().toLowerCase(), "drawable", getContext().getPackageName());
                Log.wtf("Called", "Drawable=" + i);

                    holder.icon.setImageResource(i);
                } catch (Exception e) {
                    Log.wtf("Called", "Error=" + e);
                }
        }


这是错误logcat:

08-20 19:58:24.732 12650-12650/com.bot.pokego A/Called: Drawable=android.content.res.Resources$NotFoundException: Resource ID #0x7f0200bf
08-20 19:58:24.786 12650-12650/com.bot.pokego A/Called: Drawable=2130837716


我试着清理,也删除了构建文件夹........但是还是一样的错误。

我正在使用Android Studio。

任何帮助将不胜感激 !。

谢谢 !提前 :)。

最佳答案

检查您的资源文件夹。如果将资源保留在较高版本的文件夹v21中,并在较低版本上进行测试,则可能会遇到此异常。

希望能帮助到你 !!!

07-24 18:41
查看更多