java – setContentView上的另一个资源$NotFoundException
Stack Overflow上有很多资源$NotFoundException问题,我已经审阅了它们,并尝试了各种建议无济于事.
我有一个完美的工作布局,显示一些图形与下面的一些按钮,我修改了一些按钮,并开始得到这个错误.我没有看到我的更改有什么问题,但只是为了缩小它我删除了所有按钮,所以现在我只有一个带有ImageView的LinearLayout,我仍然得到错误.我的Java: try { setContentView(R.layout.graphics); } catch (Exception e) { Log.d("DGraphActivity","setContentView crash"); } 我的XML: <?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <ImageView android:id="@+id/image2" android:layout_width="0px" android:layout_weight="2" android:layout_height="match_parent" android:scaleType="fitCenter"> </ImageView> </LinearLayout> 错误说android.content.res.Resources $NotFoundException:资源ID#0x7f030005. public static final class layout { public static final int addcomment=0x7f030000; public static final int areyousure=0x7f030001; public static final int downarrow=0x7f030002; public static final int downleftarrow=0x7f030003; public static final int downrightarrow=0x7f030004; public static final int graphics=0x7f030005; public static final int infofromoperator=0x7f030006; 我删除了gen文件夹并做了一个干净的项目没有任何改进.我还重新启动了我的电脑并明确关闭了该项目. graphics.xml文件没有明显的错误 – 它存在于与我所有其他XML文件相同的文件夹中;它没有写保护或隐藏. Eclipse不会标记任何错误或警告. 提前致谢. 解决方法
我在Android开发者谷歌小组得到了答案,我也发布了这个问题.这位富有洞察力的程序员是“Bob Smith”,只是为了给予应有的信用额度.
我的错误是它正在寻找的资源不在正确的res文件夹中.我的应用在平板电脑上以横向模式运行.在清单中,一切都被限制为以这种方式运行(实际上在代码中,它被限制为在公司随产品提供的一个特定平板电脑上运行).所有资源和布局文件都存在于layout-land中.鲍勃不知道这些,但他问了一个关键问题:我的资源文件真的在正确的res文件夹中吗? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |