android – RelativeLayout的layout_above给出“找不到资源”错误

<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文档:

The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in the R.java file).

所以,在ListView布局中的第一个btn_4引用添加一个”,你可以从Button布局中的android:id属性中删除不必要的”.

相关文章

ADB Remote ATV Android TV 的遥控器,基于 ADB Shell 命令 ...
使用Flutter自带的SearchDelegate组件实现搜索界面,通过魔改...
上篇文章讲解了怎么使用Kotlin的协程配合Retrofit发起网络请...
安卓开发——WebView+Recyclerview文章详情页,解决高度...
Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...