java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
Crash log clearly says the issue . You need to change the ListView
id . ListFragment
expects the layout to have ListView
id as @android:id/list
android:id="@android:id/list"
If you look at the ListFragment
source code , its checks for the ListView
in the layout using android.R.id.list
ID
. If the view is null it will throw an RuntimeException
View rawListView = root.findViewById(android.R.id.list);
if (!(rawListView instanceof ListView)) {
if (rawListView == null) {
throw new RuntimeException(
"Your content must have a ListView whose id attribute is " +
"'android.R.id.list'");
}
throw new RuntimeException(
"Content has view with id attribute 'android.R.id.list' "
+ "that is not a ListView class");
}
Use this Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>