我在访问 LinearLayout 内的相对布局内的 TextView 时遇到这个问题
假设我在文件 row.xml 中有这些视图
<LinearLayout>
<TextView android:id="@+id/title" />
<RelativeLayout android:id="@+id/a_parent">
<TextView android:id="@+id/a">
</RelativeLayout>
<RelativeLayout android:id="@+id/b_parent">
<TextView android:id="@+id/b">
</RelativeLayout>
</LinearLayout>
现在我想从一个活动中更改 TextViews 的值
LayoutInflater li=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout temp=(LinearLayout) li.inflate(R.layout.row, null);
((TextView)temp.findViewById(R.id.title)).setText("This is title");
RelativeLayout rl=(RelativeLayout)temp.findViewById(R.id.a_parent);
((TextView)rl.findViewById(R.id.a)).setText("an this is the content of a");
我可以成功设置id为'title'的TextView,但是在接近最后一行时出现错误。它说错误是由 android.content.res.Resources$NotFoundException: String resource ID #0x1 引起的
谁能告诉我出了什么问题,如何修复它,以及为什么代码不能按我预期的那样工作?
谢谢