app*_*oid 4 xml resources layout android
我经常在xml文件中收到此错误.这是xml文件中的代码
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_centerHorizontal="true"
android:layout_above="@id/tRowMain" // in this line i get error resource not found that matches given name
android:textColor="@color/selectLevel"
android:id="@+id/tvOnOption"
android:text="Select Mode"
/>
<TableRow android:layout_width="fill_parent" android:id="@+id/tRowMain"
android:layout_height="wrap_content" android:gravity="center" android:layout_centerVertical="true" android:layout_centerHorizontal="true" >
Run Code Online (Sandbox Code Playgroud)
//然后我检查了R.java文件,这个名字的id就在那里
public static final class id {
public static final int ibtn_retry=0x7f060006;
public static final int rLayoutMain=0x7f060000;
public static final int tRowMain=0x7f060002;
}
Run Code Online (Sandbox Code Playgroud)
请帮我弄清楚这是什么错...
谢谢
Jas*_*run 10
您应该首先使用@+id/tRowMainID语法,而不一定是您将其定义为元素ID的第一个位置.
更改:
android:layout_above="@id/tRowMain" 至 android:layout_above="@+id/tRowMain"
和
android:id="@+id/tRowMain" 至 android:id="@id/tRowMain
换句话说,在决定是否使用@+id或时@id,无论您将id分配给哪个属性都无关紧要.始终@+id在第一次在XML中提及您的ID时使用.