Anders Metnik
Anders Metnik

Reputation: 6237

Can't resolve IDs in xml

I'm trying to get a RelativeLayout up and running, so I can use it for a custom list, but when I try to space the items compared to eachother it screws up and says:

Couldn't resolve resource @id/itemName
Couldn't resolve resource @id/textPriceFrom

This is weird because textPriceFrom places itself correctly, but the price doesn't.

Here is code:

    <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>

Upvotes: 0

Views: 1748

Answers (2)

Anders Metnik
Anders Metnik

Reputation: 6237

My android:layout_width="fill_parent" made no room for a left/right off which apparently made that error.

Upvotes: 1

Andro Selva
Andro Selva

Reputation: 54332

Try to use @+id/textPriceFrom instead of @id/textPriceFrom.

i am really sorry I cudn't explain the reason. But this is how it works for me.

Upvotes: 0

Related Questions