另一个资源$ NotFoundException上的setContentView [英] Another Resources$NotFoundException on setContentView

查看:172
本文介绍了另一个资源$ NotFoundException上的setContentView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有大量的堆栈溢出资源$ NotFoundException的问题和我查看了他们,并试图提出的各种建议也没有用。

There are lots of Resources$NotFoundException questions on Stack Overflow and I've reviewed them and tried the various suggestions to no avail.

我有一个完美的工作布局下显示一些图形一些按钮,我修改了一些按钮和开始得到这个错误。我看不出什么毛病我的变化,但只是将它缩小我删除全部的按钮,所以现在我只是有一个的LinearLayout与ImageView的和我的还是得到错误。我的Java:

I had a perfectly working layout to display some graphics with some buttons underneath and I modified some of the buttons and started to get this error. I couldn't see anything wrong with my changes but just to narrow it down I deleted ALL the buttons, so now I just have a LinearLayout with an ImageView and I'm still getting the error. My 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 的。
在R.java文件资源被标识与图形。 。 。

The error says android.content.res.Resources$NotFoundException: Resource ID #0x7f030005. In the R.java file that resource is identified with the graphics . . .

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;

我删除了根文件夹和做了全新<​​/ STRONG>项目没有改善。我也重新启动我的电脑和做项目的明确关闭。没有什么明显的错误与graphics.xml文件 - 它存在于所有我的其他的XML文件相同的文件夹;它不是写保护或隐藏。 Eclipse不标记任何错误或警告它。

I deleted the gen folder and did a clean the project with no improvement. I also rebooted my PC and did an explicit close of the project. There's nothing obviously wrong with the graphics.xml file - it exists in the same folder with all my other XML files; it's not write-protected or hidden. Eclipse doesn't flag any errors or warnings for it.

先谢谢了。

推荐答案

我得到了答案,这对Android的谷歌开发者群体,在那里我还张贴了这个问题。通透的程序员是鲍勃·史密斯,只是为了给信用信贷,这是由于

I got the answer to this on the android-developers Google groups, where I also posted this question. The insightful programmer was "Bob Smith", just to give credit credit where it's due.

我的错误是,它正在寻求资源是不是在正确的res文件夹。我的应用程序在平板电脑横向模式运行。在清单都被限制在运行方式(实际上在code它约束在一个特定的平板电脑上运行,该公司船舶与他们的产品)。所有的资源和布局文件居住在布局土地。鲍勃不知道任何这一点,但他问的关键问题:?是我的资源文件确实在正确的res文件夹

My bug was that the resource it was seeking was not in the correct res folder. My app runs in landscape mode on a tablet. In the manifest everything is constrained to run that way (in fact in the code it's constrained to run on one particular tablet that the company ships with their product). All the resource and layout files live in layout-land. Bob didn't know any of this but he asked the key question: were my resource files really in the right res folder?

这篇关于另一个资源$ NotFoundException上的setContentView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆