gpt4 book ai didi

java - Android XML id "listView"未在任何地方定义

转载 作者:行者123 更新时间:2023-12-01 13:13:53 26 4
gpt4 key购买 nike

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.app.MainActivity$PlaceholderFragment" >

<ListView
android:id="@+id/listOfLists"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@id/listView1"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/listView1"
android:onClick="NewListActivity"
android:text="New List v2" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/listView1"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/listView1"
android:text="Receipts"
android:onClick="ReceiptsActivity" />

</RelativeLayout>

我收到一条错误消息

Multiple annotations found at this line:
- The id "listView" is not defined anywhere. Did you mean one of {listView1, listView2} ?
- error: Error: No resource found that matches the given name (at 'layout_alignEnd' with value '@id/

我没有使用listView,我使用的是listView1。

最佳答案

改变这个

android:layout_alignEnd="@id/listView1"

android:layout_alignEnd="@id/listOfLists"

因为你有

<ListView
android:id="@+id/listOfLists"

其他地方同样替换为@+id/listOfLists

编辑:

使用

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.app.MainActivity$PlaceholderFragment" >

<ListView
android:id="@+id/listOfLists"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@id/listOfLists"
android:layout_alignParentTop="true"
android:layout_alignRight="@id/listOfLists"
android:onClick="NewListActivity"
android:text="New List v2" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/listOfLists"
android:layout_alignParentBottom="true"
android:layout_alignRight="@id/listOfLists"
android:text="Receipts"
android:onClick="ReceiptsActivity" />

</RelativeLayout>

关于java - Android XML id "listView"未在任何地方定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22616489/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com