【发布时间】:2020-09-15 15:15:44
【问题描述】:
我有一个从 url 获取数据然后将其放入列表视图的应用程序。我想从两个 url 执行此操作,因此我有两个片段和两个 xml 文件,其中会发生这种情况。但我得到了错误
Your content must have a ListView whose id attribute is 'android.R.id.list'
我将 id 设置为在我的 xml 文件中列出,但是当有两个 xml 文件时不会有问题吗?我不能拥有相同的 id 对吗?
我的 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>
<?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"
android:orientation="vertical"
tools:context=".DetailsFragment">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list"/>
</Framelayout>
【问题讨论】:
标签: android listview android-fragments