1

I have a strange issue after using Eclipse GUI to edit a layout. It is telling me that the resource tvVersionLabel cannot be found. Anything obvious?

        <TextView
            android:id="@+id/tvVersionLabel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:gravity="center"
            android:text="Version: "
            android:textColor="@color/light_gray"
            android:textSize="13dip" />

        <TextView
            android:id="@+id/tvVersionNumber"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/tvVersionLabel"
            android:gravity="center"
            android:text="default"
            android:textColor="#ffffff"
            android:textSize="13dip" />
Heron
  • 329
  • 2
  • 5
  • 15
  • use this - `android:layout_toRightOf="@+id/tvVersionLabel"` – Amresh Oct 29 '13 at 13:03
  • Are the `TextView`s really in this order in your layout? It should work this way. If the order is switched i.e. one refers to the other before it is declared, you'll encounter this error message. One way to fix it is to use "@+id/..." in the reference as well, or just fix the declaration/reference order. – laalto Oct 29 '13 at 13:10

2 Answers2

8

Change this:

android:layout_toRightOf="@id/tvVersionLabel"

to this:

android:layout_toRightOf="@+id/tvVersionLabel"

The idea is the ids you have declared have different values and that's why the first view cannot be found if you declare it like that. More info (that you may be aware of), can be found here.

Community
  • 1
  • 1
gunar
  • 14,660
  • 7
  • 56
  • 87
2

simply used @+id/ for android:layout_toRightOf

Abhishek Patel
  • 4,280
  • 1
  • 24
  • 38