Android 12 Developer Preview is here! Try it out, and give us your feedback!


open class ListFragment : Fragment

Static library support version of the framework's Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.


Public constructors

Public methods
open ListAdapter?

Get the ListAdapter associated with this fragment's ListView.

open ListView

Get the fragment's list view widget.

open Long

Get the cursor row ID of the currently selected list item.

open Int

Get the position of the currently selected list item.

open View?
onCreateView(@NonNull inflater: LayoutInflater, @Nullable container: ViewGroup?, @Nullable savedInstanceState: Bundle?)

Provide default implementation to return a simple list view.

open Unit

Detach from list view.

open Unit
onListItemClick(@NonNull l: ListView, @NonNull v: View, position: Int, id: Long)

This method will be called when an item in the list is selected.

open Unit
onViewCreated(@NonNull view: View, @Nullable savedInstanceState: Bundle?)

Attach to list view once the view hierarchy has been created.


Get the ListAdapter associated with this fragment's ListView.

open Unit
setEmptyText(@Nullable text: CharSequence?)

The default content for a ListFragment has a TextView that can be shown when the list is empty.

open Unit
setListAdapter(@Nullable adapter: ListAdapter?)

Provide the cursor for the list view.

open Unit

Control whether the list is being displayed.

open Unit

Like setListShown(boolean), but no animation is used when transitioning from the previous state.

open Unit
setSelection(position: Int)

Set the currently selected list item to the specified position with the adapter's data

Inherited functions