无法在xml中解析ID
问题描述:
我试图让RelativeLayout
启动并运行,因此我可以将它用于自定义列表 ,但是当我尝试将项目间的空间相互比较时,它会将其拧紧并说:无法在xml中解析ID
无法解析资源@ ID/ITEMNAME
无法解析资源@ ID/textPriceFrom
这是奇怪,因为textPriceFrom
地方本身正确,但价格却没有。
这里是代码:
<RelativeLayout
android:id="@+id/mainlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/itemName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:text="A good day"
android:textSize="23dip"
android:textStyle="bold" />
<TextView
android:id="@+id/textPriceFrom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/itemName"
android:layout_margin="3dip"
android:text="@string/frapris"
android:textSize="15dip"
android:textStyle="normal" />
<TextView
android:id="@+id/textPrice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:layout_toLeftOf="@id/textPriceFrom"
android:text="145,95"
android:textSize="10dip"
android:textStyle="normal" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="3dip"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
答
我的android:layout_width="fill_parent"
没有显示出错误的左/右关空间。
答
尝试使用@+id/textPriceFrom
而不是@id/textPriceFrom
。
我真的很抱歉,我不能解释原因。但这是它对我的作用。
+3
我想你只是在创建一个新的id时添加+,而不是指现有的id。 – barry
+0
不知道为什么你会张贴作为答案tbh ;-) 你可以尝试和C/P它,并检查它是否可以在你的机器上? –
哇 - 我原以为只会让左/右视图不可见,不会导致错误 – barry
我也是这样:但是那是它,当我改变它时,它没有问题的工作:-) –