Android listview错误:您的内容必须具有id属性为';android.R.id.list';但是我有两个列表视图

Android listview错误:您的内容必须具有id属性为';android.R.id.list';但是我有两个列表视图,android,listview,android-fragments,Android,Listview,Android Fragments,我有一个应用程序,它从url获取数据,然后将其放入listview。我想从两个URL执行此操作,因此我有两个片段和两个xml文件,在其中发生这种情况。但是我得到了错误 您的内容必须具有id属性为“android.R.id.list”的ListView 我将id设置为在xml文件中列出,但是如果有两个xml文件,会不会出现问题?我不能有相同的身份证,对吗 我的xml文件: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xm

我有一个应用程序,它从url获取数据,然后将其放入listview。我想从两个URL执行此操作,因此我有两个片段和两个xml文件,在其中发生这种情况。但是我得到了错误
您的内容必须具有id属性为“android.R.id.list”的ListView
我将id设置为在xml文件中列出,但是如果有两个xml文件,会不会出现问题?我不能有相同的身份证,对吗

我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
    tools:context=".ListFragment">

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/list"/>

</FrameLayout> 



不,这不会产生任何问题,因为android会在运行时解决复制问题,而且listview已经过时,您应该开始使用recyclerview,它比listview好得多。

您的
活动有问题。
可能是您扩展了
ListActivity。

您必须扩展
活动
才能解决您的问题

第二个解决方案是 将id定义为以下格式

<ListView 
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>


解决了您的问题?谢谢,是id!
<ListView 
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>