MartinS
MartinS

Reputation: 6244

RelativeLayout - Couldnt resolve resource

I have a relative layout which works fine at runtime but in the Eclipse graphical layout designer I receive the exception

Couldn't resolve resource @id/imgSessionOutcome_Product1_Icon

The resource of the imageview is defined and is before the references to it, so I can't quite see what the issue is ? The exception is listed twice so both references to it fail.

I've saved/cleaned project to make sure resources rebuilt, still same error.

Eclipse Version: Helios Service Release 2 running on OSX with latest updates etc.

    <RelativeLayout
    android:id="@+id/lySessionOutcome_Product1"
    android:layout_width="match_parent"
    android:layout_height="55dip"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="5dip"
    android:orientation="vertical" 
    android:visibility="gone">

    <ImageView
        android:id="@+id/imgSessionOutcome_Product1_Icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="10dip"
        android:src="@drawable/gr_bag_bc" />

    <TextView
        android:id="@+id/tvSessionOutcome_Product1_Description"
        android:layout_width="fill_parent"
        android:layout_height="26dip"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_toRightOf="@id/imgSessionOutcome_Product1_Icon"
        android:ellipsize="marquee"
        android:singleLine="false"
        android:text="Description" />

    <TextView
        android:id="@+id/tvSessionOutcome_Product1_Type"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/tvSessionOutcome_Product1_Description"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_alignWithParentIfMissing="true"
        android:layout_toRightOf="@id/imgSessionOutcome_Product1_Icon"
        android:gravity="center_vertical"
        android:text="Product type"
        android:textAppearance="@style/largeBlack" />
</RelativeLayout>

Upvotes: 1

Views: 3423

Answers (1)

Aashish Bhatnagar
Aashish Bhatnagar

Reputation: 2605

try using

android:layout_toRightOf="@+id/imgSessionOutcome_Product1_Icon"

Well I answered this long time ago I didn't knew why it works then and I am still not sure but based on my observation I think using + sign instead creates a temporary reference to the view so that we can view it in Android layout editor, actual anchor view gets picked at runtime only.

If you wont use the + sign it works fine at runtime as stated in the question itself. Please correct me if I am wrong.

Upvotes: 5

Related Questions