<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:layout_above="@id/btn_4" <-- this line error: No resource found
android:layout_width="match_parent"
android:layout_height="200dp" />
<Button android:id="@+id/btn_4" <-- I declare the id here
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
</RelativeLayout>
有什么建议?
据我所知,第一次在布局xml中使用id时,它需要在它前面加上一个+号。
来自Declaring Layout文档:
加号(+)表示这是一个新的资源名称,必须创建并添加到我们的资源中(在R.java文件中)。
因此,在ListView布局中的第一个btn_4引用中添加一个“+”,您可以从Button布局中的android:id属性中删除不必要的“+”。
声明相对布局时,必须使用android:layout_above="@+id/layoutToBeAbove"
否则,系统不知道你指的是什么。
该声明将指向同一资源。
希望这有帮助!
在声明ListView
btn_4之后声明Button
list_1,因为它试图在android:layout_above="@id/btn_4"
中引用它。