Your content must have a ListView whose id attribute is 'android.R.id.list'
Rename the id of your ListView like this,
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Since you are using ListActivity
your xml file must specify the keyword android while mentioning to a ID.
If you need a custom ListView
then instead of Extending a ListActivity
, you have to simply extend an Activity
and should have the same id without the keyword android.
java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
The problem is here :
android:id="@+id/list"
you are adding a new id for your ListView but ListFragment needs a default Android ListView Id
change your ListView Id to :
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
your content must have a listview whose id attribute is 'android.r.id.list'
Your listView with id = "@android:id/list" must be part of activity, not a fragment. But in your code your list view is part of fragment. You can use common activity instead of listActivity and ListFragment (as parent of your PlaceholderFragment class). Or you can move your list from your fragment to your activity.
Android listview error: Your content must have a ListView whose id attribute is 'android.R.id.list' but i have two listviews
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"/>
java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'- error
Try this..
Your using ListActivity
then id for your ListView
in your layout should be @android:id/list
<?xml version="1.0" encoding="UTF-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ListView>
and also Remove ListView listView = (ListView) findViewById(R.id.tourList);
then
// Get listview
ListView lv = getListView();
tourNumberListAdapter = new TourNumberListAdapter(this, cursorTourNumberInfo);
setListAdapter(tourNumberListAdapter);
lv.setOnItemClickListener(new OnItemClickListener() {
ListView whose id attribute is 'android.R.id.list' Error when I have the ListView id set correctly
android:id="@android:id/list"
works perfectly, My issue was I had a Splash screen that inherited a base class which was inheriting ListActivity and had no ListView defined for the splash screen activity. I have altered the SplashScreen to just inherit Activity. All works as expected.
Related Topics
How to Disable Landscape Mode in Android
What's the Best Way to Limit Text Length of Edittext in Android
Disable Scrolling in All Mobile Devices
How to Start Genymotion Device
How to Control the Width and Height of the Default Alert Dialog in Android
How to Run a Method Every X Seconds
How to Determine Mime Type of File in Android
Why Does Layoutinflater Ignore the Layout_Width and Layout_Height Layout Parameters I'Ve Specified
How to Change the Text on the Action Bar
How to Detect Android App Uninstall
Android Chrome Ignoring -Webkit-Text-Size-Adjust:None Property. Text Is Being Scaled When Zoomed Out
Generate Sha-1 for Flutter/React-Native/Android-Native App
How to Get an APK File from an Android Device
Classnotfoundexception After Adt Update
How to Add Window Android.View.Viewroot$W@44Da9Bc0 -- Permission Denied for This Window Type