2012-06-15 37 views
0

我試圖讓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> 

回答

1

我的android:layout_width="fill_parent"沒有顯示出錯誤的左/右關空間。

+0

哇 - 我原以爲只會讓左/右視圖不可見,不會導致錯誤 – barry

+0

我也是這樣:但是那是它,當我改變它時,它沒有問題的工作:-) –

0

嘗試使用@+id/textPriceFrom而不是@id/textPriceFrom

我真的很抱歉,我不能解釋原因。但這是它對我的作用。

+3

我想你只是在創建一個新的id時添加+,而不是指現有的id。 – barry

+0

不知道爲什麼你會張貼作爲答案tbh ;-) 你可以嘗試和C/P它,並檢查它是否可以在你的機器上? –