代码如下:
r.java
        public static final int test_age=0x7f050000;异常如下:
07-22 05:52:28.450: ERROR/AndroidRuntime(770): android.content.res.Resources$NotFoundException: Resource ID #0x7f050000 type #0x12 is not validage.xml 如下:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/test_age"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">
      <EditText android:id="@+id/age"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="age"
android:numeric="integer"
/>
</LinearLayout>
调用的代码:View view = inflater.inflate(R.id.test_age, null);走到这儿就有错,不知道为什么,求解!!!

解决方案 »

  1.   

    View view = inflater.inflate(R.layout.age, null);
      

  2.   


    r.java
      public static final int test_age=0x7f050000;异常如下:
    07-22 05:52:28.450: ERROR/AndroidRuntime(770): android.content.res.Resources$NotFoundException: Resource ID #0x7f050000 type #0x12 is not validage.xml 如下:<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/test_age"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content">
       <EditText android:id="@+id/age"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="age"
    android:numeric="integer"
    />
    </LinearLayout>
    调用的代码:View view = inflater.inflate(R.id.test_age, null);很明显,你的Id不匹配导致异常NotFoundException
      

  3.   

    厄...我想不是这个问题吧,LZ的意思是获取linearlayout的对象,linearlayout本身就是一个view类继承下来的
      

  4.   

    通过inflater的参数应该是layout目录下的一个文件,不应该是一个ID
      

  5.   

    See here:
    http://code.google.com/p/android/issues/detail?id=2726