android.content.res.Resources$Not

xuhui1986 2010-07-22 02:08:48
代码如下:
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 valid

age.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);

走到这儿就有错,不知道为什么,求解!!!
...全文
1072 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xwanglyxwangly 2011-04-26
  • 打赏
  • 举报
回复
See here:
http://code.google.com/p/android/issues/detail?id=2726
长富 2010-11-07
  • 打赏
  • 举报
回复
通过inflater的参数应该是layout目录下的一个文件,不应该是一个ID
纠结的木棉花 2010-11-01
  • 打赏
  • 举报
回复

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 valid

age.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
长富 2010-11-01
  • 打赏
  • 举报
回复
View view = inflater.inflate(R.layout.age, null);
dinjay 2010-11-01
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zhq56030207 的回复:]
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 n……
[/Quote]
厄...我想不是这个问题吧,LZ的意思是获取linearlayout的对象,linearlayout本身就是一个view类继承下来的

80,350

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧