Skip to content Skip to sidebar Skip to footer

Listfragment Crashes When Tab Selected And Gives Errors

When i run my app everything runs perfectly until i select the third tab that consist the listfragment i made so it displays a listview with data and image, once it is selected the

Solution 1:

You need to have a listview with id as below in friends_list.xml

<ListView android:id="@android:id/list"

Whatever applies to ListActivity applies to ListFragment. More info @

Quoting docs

ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code)

So if you inflate a layout in ListFragment you need to have a ListView with the id @android:id/list in the fragments layout.

Edit:

Notice android:id="@+id/list" vs android:id="@android:id/list". I suggested android:id="@android:id/list"

Post a Comment for "Listfragment Crashes When Tab Selected And Gives Errors"