未找到资源异常
Resources Not Found Exception
您好,我在我的适配器代码中遇到 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 中并在较低版本上进行测试,您可能会遇到此异常。
希望对您有所帮助!!!
您好,我在我的适配器代码中遇到 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 中并在较低版本上进行测试,您可能会遇到此异常。
希望对您有所帮助!!!