1

I have an app which gets data from a url and then puts it into a listview. I want to do this from two urls so i have two fragments and two xml files in which this happens. But i get the error Your content must have a ListView whose id attribute is 'android.R.id.list' I have the id set to list in my xml file, but wont there be a problem when there are two xml files? I cant have the same id right?

My xml files:

<?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>
ldjsa
  • 55
  • 6

2 Answers2

1

no it won't create any problem as android will solve the duplication at runtime and also listview is outdated and you should start using recyclerview,which is much better than listview.

Aashit Shah
  • 578
  • 3
  • 9
0

Problem with your Activity. May be you extend ListActivity.

You have to extend an Activity will resolve your issue

Second solutions is define id as below format

<ListView 
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
Dinesh
  • 1,410
  • 2
  • 16
  • 29