Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited XML Attrs](https://developer.android.com/reference/android/app/ListFragment#inhattrs) \| [Inherited Constants](https://developer.android.com/reference/android/app/ListFragment#inhconstants) \| [Ctors](https://developer.android.com/reference/android/app/ListFragment#pubctors) \| [Methods](https://developer.android.com/reference/android/app/ListFragment#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/ListFragment#inhmethods)

# ListFragment

*** ** * ** ***

` public class ListFragment `   
` ` ` extends https://developer.android.com/reference/android/app/Fragment ` ` `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.app.Fragment](https://developer.android.com/reference/android/app/Fragment) ||
|   | ↳ | android.app.ListFragment |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 28.**   

Use the [Support Library](https://developer.android.com/tools/extras/support-library) `https://developer.android.com/reference/androidx/fragment/app/ListFragment.html` for consistent behavior across all devices and access to [Lifecycle](https://developer.android.com/topic/libraries/architecture/lifecycle).

A fragment that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.

ListFragment hosts a `https://developer.android.com/reference/android/widget/ListView` object that can be bound to different data sources, typically either an array or a Cursor holding query results. Binding, screen layout, and row layout are discussed in the following sections.

**Screen Layout**

ListFragment has a default layout that consists of a single list view. However, if you desire, you can customize the fragment layout by returning your own view hierarchy from `https://developer.android.com/reference/android/app/ListFragment#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)`. To do this, your view hierarchy *must* contain a ListView object with the id "@android:id/list" (or `https://developer.android.com/reference/android/R.id#list` if it's in code)

Optionally, your view hierarchy can contain another view object of any type to display when the list view is empty. This "empty list" notifier must have an id "android:empty". Note that when an empty view is present, the list view will be hidden when there is no data to display.

The following code demonstrates an (ugly) custom list layout. It has a list with a green background, and an alternate red "no data" message.

```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="8dp"
        android:paddingRight="8dp">

    <ListView android:id="@id/android:list"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#00FF00"
              android:layout_weight="1"
              android:drawSelectorOnTop="false"/>

    <TextView android:id="@id/android:empty"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="#FF0000"
              android:text="No data"/>
</LinearLayout>
```

**Row Layout**

You can specify the layout of individual rows in the list. You do this by specifying a layout resource in the ListAdapter object hosted by the fragment (the ListAdapter binds the ListView to the data; more on this later).

A ListAdapter constructor takes a parameter that specifies a layout resource for each row. It also has two additional parameters that let you specify which data field to associate with which object in the row layout resource. These two parameters are typically parallel arrays.

Android provides some standard row layout resources. These are in the `https://developer.android.com/reference/android/R.layout` class, and have names such as simple_list_item_1, simple_list_item_2, and two_line_list_item. The following layout XML is the source for the resource two_line_list_item, which displays two data fields,one above the other, for each list row.

```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView android:id="@+id/text1"
        android:textSize="16sp"
        android:textStyle="bold"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <TextView android:id="@+id/text2"
        android:textSize="16sp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>
```

You must identify the data bound to each TextView object in this layout. The syntax for this is discussed in the next section.

**Binding to Data**

You bind the ListFragment's ListView object to data using a class that implements the `https://developer.android.com/reference/android/widget/ListAdapter` interface. Android provides two standard list adapters: `https://developer.android.com/reference/android/widget/SimpleAdapter` for static data (Maps), and `https://developer.android.com/reference/android/widget/SimpleCursorAdapter` for Cursor query results.

You **must** use `https://developer.android.com/reference/android/app/ListFragment#setListAdapter(android.widget.ListAdapter)` to associate the list with an adapter. Do not directly call `https://developer.android.com/reference/android/widget/ListView#setAdapter(android.widget.ListAdapter)` or else important initialization will be skipped.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/ListFragment#setListAdapter(android.widget.ListAdapter)`
- `https://developer.android.com/reference/android/widget/ListView`

## Summary

### Inherited XML attributes

From class `https://developer.android.com/reference/android/app/Fragment` [`android:fragmentAllowEnterTransitionOverlap`](https://developer.android.com/reference/android/app/Fragment#attr_android:fragmentAllowEnterTransitionOverlap) Sets whether the enter and exit transitions should overlap when transitioning forward. [`android:fragmentAllowReturnTransitionOverlap`](https://developer.android.com/reference/android/app/Fragment#attr_android:fragmentAllowReturnTransitionOverlap) Sets whether the enter and exit transitions should overlap when transitioning because of popping the back stack. [`android:fragmentEnterTransition`](https://developer.android.com/reference/android/app/Fragment#attr_android:fragmentEnterTransition) The Transition that will be used to move Views into the initial scene. [`android:fragmentExitTransition`](https://developer.android.com/reference/android/app/Fragment#attr_android:fragmentExitTransition) The Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack. [`android:fragmentReenterTransition`](https://developer.android.com/reference/android/app/Fragment#attr_android:fragmentReenterTransition) The Transition that will be used to move Views in to the scene when returning due to popping a back stack. [`android:fragmentSharedElementEnterTransition`](https://developer.android.com/reference/android/app/Fragment#attr_android:fragmentSharedElementEnterTransition) The Transition that will be used for shared elements transferred into the content Scene. [`android:fragmentSharedElementReturnTransition`](https://developer.android.com/reference/android/app/Fragment#attr_android:fragmentSharedElementReturnTransition) The Transition that will be used for shared elements transferred back during a pop of the back stack.

### Inherited constants

From interface `https://developer.android.com/reference/android/content/ComponentCallbacks2` `int` `https://developer.android.com/reference/android/content/ComponentCallbacks2#TRIM_MEMORY_BACKGROUND`

Level for `https://developer.android.com/reference/android/content/ComponentCallbacks2#onTrimMemory(int)`: the process has gone on to the LRU list.
`int` `https://developer.android.com/reference/android/content/ComponentCallbacks2#TRIM_MEMORY_COMPLETE`

*This constant was deprecated in API level 35. Apps are not notified of this level since API level 34*
`int` `https://developer.android.com/reference/android/content/ComponentCallbacks2#TRIM_MEMORY_MODERATE`

*This constant was deprecated in API level 35. Apps are not notified of this level since API level 34*
`int` `https://developer.android.com/reference/android/content/ComponentCallbacks2#TRIM_MEMORY_RUNNING_CRITICAL`

*This constant was deprecated in API level 35. Apps are not notified of this level since API level 34*
`int` `https://developer.android.com/reference/android/content/ComponentCallbacks2#TRIM_MEMORY_RUNNING_LOW`

*This constant was deprecated in API level 35. Apps are not notified of this level since API level 34*
`int` `https://developer.android.com/reference/android/content/ComponentCallbacks2#TRIM_MEMORY_RUNNING_MODERATE`

*This constant was deprecated in API level 35. Apps are not notified of this level since API level 34*
`int` `https://developer.android.com/reference/android/content/ComponentCallbacks2#TRIM_MEMORY_UI_HIDDEN`

Level for `https://developer.android.com/reference/android/content/ComponentCallbacks2#onTrimMemory(int)`: the process had been showing a user interface, and is no longer doing so.

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/ListFragment#ListFragment()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/widget/ListAdapter` | ` https://developer.android.com/reference/android/app/ListFragment#getListAdapter()() ` Get the ListAdapter associated with this fragment's ListView. |
| ` https://developer.android.com/reference/android/widget/ListView` | ` https://developer.android.com/reference/android/app/ListFragment#getListView()() ` Get the fragment's list view widget. |
| ` long` | ` https://developer.android.com/reference/android/app/ListFragment#getSelectedItemId()() ` Get the cursor row ID of the currently selected list item. |
| ` int` | ` https://developer.android.com/reference/android/app/ListFragment#getSelectedItemPosition()() ` Get the position of the currently selected list item. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/app/ListFragment#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)(https://developer.android.com/reference/android/view/LayoutInflater inflater, https://developer.android.com/reference/android/view/ViewGroup container, https://developer.android.com/reference/android/os/Bundle savedInstanceState) ` Provide default implementation to return a simple list view. |
| ` void` | ` https://developer.android.com/reference/android/app/ListFragment#onDestroyView()() ` Detach from list view. |
| ` void` | ` https://developer.android.com/reference/android/app/ListFragment#onListItemClick(android.widget.ListView,%20android.view.View,%20int,%20long)(https://developer.android.com/reference/android/widget/ListView l, https://developer.android.com/reference/android/view/View v, int position, long id) ` This method will be called when an item in the list is selected. |
| ` void` | ` https://developer.android.com/reference/android/app/ListFragment#onViewCreated(android.view.View,%20android.os.Bundle)(https://developer.android.com/reference/android/view/View view, https://developer.android.com/reference/android/os/Bundle savedInstanceState) ` Attach to list view once the view hierarchy has been created. |
| ` void` | ` https://developer.android.com/reference/android/app/ListFragment#setEmptyText(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence text) ` The default content for a ListFragment has a TextView that can be shown when the list is empty. |
| ` void` | ` https://developer.android.com/reference/android/app/ListFragment#setListAdapter(android.widget.ListAdapter)(https://developer.android.com/reference/android/widget/ListAdapter adapter) ` Provide the cursor for the list view. |
| ` void` | ` https://developer.android.com/reference/android/app/ListFragment#setListShown(boolean)(boolean shown) ` Control whether the list is being displayed. |
| ` void` | ` https://developer.android.com/reference/android/app/ListFragment#setListShownNoAnimation(boolean)(boolean shown) ` Like `https://developer.android.com/reference/android/app/ListFragment#setListShown(boolean)`, but no animation is used when transitioning from the previous state. |
| ` void` | ` https://developer.android.com/reference/android/app/ListFragment#setSelection(int)(int position) ` Set the currently selected list item to the specified position with the adapter's data |

### Inherited methods

From class ` https://developer.android.com/reference/android/app/Fragment ` ` void` ` https://developer.android.com/reference/android/app/Fragment#dump(java.lang.String,%20java.io.FileDescriptor,%20java.io.PrintWriter,%20java.lang.String[])(https://developer.android.com/reference/java/lang/String prefix, https://developer.android.com/reference/java/io/FileDescriptor fd, https://developer.android.com/reference/java/io/PrintWriter writer, https://developer.android.com/reference/java/lang/String args) `

Print the Fragments's state into the given stream.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) `

Subclasses can not override equals().
` final https://developer.android.com/reference/android/app/Activity` ` https://developer.android.com/reference/android/app/Fragment#getActivity()() `

Return the Activity this fragment is currently associated with.
` boolean` ` https://developer.android.com/reference/android/app/Fragment#getAllowEnterTransitionOverlap()() `

Returns whether the exit transition and enter transition overlap or not.
` boolean` ` https://developer.android.com/reference/android/app/Fragment#getAllowReturnTransitionOverlap()() `

Returns whether the return transition and reenter transition overlap or not.
` final https://developer.android.com/reference/android/os/Bundle` ` https://developer.android.com/reference/android/app/Fragment#getArguments()() `

Return the arguments supplied to `https://developer.android.com/reference/android/app/Fragment#setArguments(android.os.Bundle)`, if any.
` final https://developer.android.com/reference/android/app/FragmentManager` ` https://developer.android.com/reference/android/app/Fragment#getChildFragmentManager()() `

Return a private FragmentManager for placing and managing Fragments inside of this Fragment.
` https://developer.android.com/reference/android/content/Context` ` https://developer.android.com/reference/android/app/Fragment#getContext()() `

Return the `https://developer.android.com/reference/android/content/Context` this fragment is currently associated with.
` https://developer.android.com/reference/android/transition/Transition` ` https://developer.android.com/reference/android/app/Fragment#getEnterTransition()() `

Returns the Transition that will be used to move Views into the initial scene.
` https://developer.android.com/reference/android/transition/Transition` ` https://developer.android.com/reference/android/app/Fragment#getExitTransition()() `

Returns the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.
` final https://developer.android.com/reference/android/app/FragmentManager` ` https://developer.android.com/reference/android/app/Fragment#getFragmentManager()() `

Return the FragmentManager for interacting with fragments associated with this fragment's activity.
` final https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/android/app/Fragment#getHost()() `

Return the host object of this fragment.
` final int` ` https://developer.android.com/reference/android/app/Fragment#getId()() `

Return the identifier this fragment is known by.
` final https://developer.android.com/reference/android/view/LayoutInflater` ` https://developer.android.com/reference/android/app/Fragment#getLayoutInflater()() `

Returns the cached LayoutInflater used to inflate Views of this Fragment.
` https://developer.android.com/reference/android/app/LoaderManager` ` https://developer.android.com/reference/android/app/Fragment#getLoaderManager()() `

*This method is deprecated. Use `https://developer.android.com/reference/androidx/fragment/app/Fragment.html#getLoaderManager()`*
` final https://developer.android.com/reference/android/app/Fragment` ` https://developer.android.com/reference/android/app/Fragment#getParentFragment()() `

Returns the parent Fragment containing this Fragment.
` https://developer.android.com/reference/android/transition/Transition` ` https://developer.android.com/reference/android/app/Fragment#getReenterTransition()() `

Returns the Transition that will be used to move Views in to the scene when returning due to popping a back stack.
` final https://developer.android.com/reference/android/content/res/Resources` ` https://developer.android.com/reference/android/app/Fragment#getResources()() `

Return `getActivity().getResources()`.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#getRetainInstance()() ` ` https://developer.android.com/reference/android/transition/Transition` ` https://developer.android.com/reference/android/app/Fragment#getReturnTransition()() `

Returns the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.
` https://developer.android.com/reference/android/transition/Transition` ` https://developer.android.com/reference/android/app/Fragment#getSharedElementEnterTransition()() `

Returns the Transition that will be used for shared elements transferred into the content Scene.
` https://developer.android.com/reference/android/transition/Transition` ` https://developer.android.com/reference/android/app/Fragment#getSharedElementReturnTransition()() `

Return the Transition that will be used for shared elements transferred back during a pop of the back stack.
` final https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/android/app/Fragment#getString(int)(int resId) `

Return a localized string from the application's package's default string table.
` final https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/android/app/Fragment#getString(int,%20java.lang.Object[])(int resId, https://developer.android.com/reference/java/lang/Object formatArgs) `

Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined in `https://developer.android.com/reference/java/util/Formatter` and `https://developer.android.com/reference/java/lang/String#format(java.lang.String,%20java.lang.Object[])`.
` final https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/android/app/Fragment#getTag()() `

Get the tag name of the fragment, if specified.
` final https://developer.android.com/reference/android/app/Fragment` ` https://developer.android.com/reference/android/app/Fragment#getTargetFragment()() `

Return the target fragment set by `https://developer.android.com/reference/android/app/Fragment#setTargetFragment(android.app.Fragment,%20int)`.
` final int` ` https://developer.android.com/reference/android/app/Fragment#getTargetRequestCode()() `

Return the target request code set by `https://developer.android.com/reference/android/app/Fragment#setTargetFragment(android.app.Fragment,%20int)`.
` final https://developer.android.com/reference/java/lang/CharSequence` ` https://developer.android.com/reference/android/app/Fragment#getText(int)(int resId) `

Return a localized, styled CharSequence from the application's package's default string table.
` boolean` ` https://developer.android.com/reference/android/app/Fragment#getUserVisibleHint()() ` ` https://developer.android.com/reference/android/view/View` ` https://developer.android.com/reference/android/app/Fragment#getView()() `

Get the root view for the fragment's layout (the one returned by `https://developer.android.com/reference/android/app/Fragment#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)`), if provided.
` final int` ` https://developer.android.com/reference/android/app/Fragment#hashCode()() `

Subclasses can not override hashCode().
` static https://developer.android.com/reference/android/app/Fragment` ` https://developer.android.com/reference/android/app/Fragment#instantiate(android.content.Context,%20java.lang.String)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/java/lang/String fname) `

Like `https://developer.android.com/reference/android/app/Fragment#instantiate(android.content.Context,%20java.lang.String,%20android.os.Bundle)` but with a null argument Bundle.
` static https://developer.android.com/reference/android/app/Fragment` ` https://developer.android.com/reference/android/app/Fragment#instantiate(android.content.Context,%20java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/java/lang/String fname, https://developer.android.com/reference/android/os/Bundle args) `

Create a new instance of a Fragment with the given class name.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#isAdded()() `

Return true if the fragment is currently added to its activity.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#isDetached()() `

Return true if the fragment has been explicitly detached from the UI.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#isHidden()() `

Return true if the fragment has been hidden.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#isInLayout()() `

Return true if the layout is included as part of an activity view hierarchy via the \<fragment\> tag.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#isRemoving()() `

Return true if this fragment is currently being removed from its activity.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#isResumed()() `

Return true if the fragment is in the resumed state.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#isStateSaved()() `

Returns true if this fragment is added and its state has already been saved by its host.
` final boolean` ` https://developer.android.com/reference/android/app/Fragment#isVisible()() `

Return true if the fragment is currently visible to the user.
` void` ` https://developer.android.com/reference/android/app/Fragment#onActivityCreated(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Called when the fragment's activity has been created and this fragment's view hierarchy instantiated.
` void` ` https://developer.android.com/reference/android/app/Fragment#onActivityResult(int,%20int,%20android.content.Intent)(int requestCode, int resultCode, https://developer.android.com/reference/android/content/Intent data) `

Receive the result from a previous call to `https://developer.android.com/reference/android/app/Fragment#startActivityForResult(android.content.Intent,%20int)`.
` void` ` https://developer.android.com/reference/android/app/Fragment#onAttach(android.app.Activity)(https://developer.android.com/reference/android/app/Activity activity) `

*This method was deprecated in API level 23. Use `https://developer.android.com/reference/android/app/Fragment#onAttach(android.content.Context)` instead.*
` void` ` https://developer.android.com/reference/android/app/Fragment#onAttach(android.content.Context)(https://developer.android.com/reference/android/content/Context context) `

Called when a fragment is first attached to its context.
` void` ` https://developer.android.com/reference/android/app/Fragment#onAttachFragment(android.app.Fragment)(https://developer.android.com/reference/android/app/Fragment childFragment) `

Called when a fragment is attached as a child of this fragment.
` void` ` https://developer.android.com/reference/android/app/Fragment#onConfigurationChanged(android.content.res.Configuration)(https://developer.android.com/reference/android/content/res/Configuration newConfig) `

Called by the system when the device configuration changes while your component is running. If you override this method you *must* call through to the superclass implementation.
` boolean` ` https://developer.android.com/reference/android/app/Fragment#onContextItemSelected(android.view.MenuItem)(https://developer.android.com/reference/android/view/MenuItem item) `

This hook is called whenever an item in a context menu is selected.
` void` ` https://developer.android.com/reference/android/app/Fragment#onCreate(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Called to do initial creation of a fragment.
` https://developer.android.com/reference/android/animation/Animator` ` https://developer.android.com/reference/android/app/Fragment#onCreateAnimator(int,%20boolean,%20int)(int transit, boolean enter, int nextAnim) `

Called when a fragment loads an animation.
` void` ` https://developer.android.com/reference/android/app/Fragment#onCreateContextMenu(android.view.ContextMenu,%20android.view.View,%20android.view.ContextMenu.ContextMenuInfo)(https://developer.android.com/reference/android/view/ContextMenu menu, https://developer.android.com/reference/android/view/View v, https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo menuInfo) `

Called when a context menu for the `view` is about to be shown.
` void` ` https://developer.android.com/reference/android/app/Fragment#onCreateOptionsMenu(android.view.Menu,%20android.view.MenuInflater)(https://developer.android.com/reference/android/view/Menu menu, https://developer.android.com/reference/android/view/MenuInflater inflater) `

Initialize the contents of the Activity's standard options menu.
` https://developer.android.com/reference/android/view/View` ` https://developer.android.com/reference/android/app/Fragment#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)(https://developer.android.com/reference/android/view/LayoutInflater inflater, https://developer.android.com/reference/android/view/ViewGroup container, https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Called to have the fragment instantiate its user interface view.
` void` ` https://developer.android.com/reference/android/app/Fragment#onDestroy()() `

Called when the fragment is no longer in use.
` void` ` https://developer.android.com/reference/android/app/Fragment#onDestroyOptionsMenu()() `

Called when this fragment's option menu items are no longer being included in the overall options menu.
` void` ` https://developer.android.com/reference/android/app/Fragment#onDestroyView()() `

Called when the view previously created by `https://developer.android.com/reference/android/app/Fragment#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)` has been detached from the fragment.
` void` ` https://developer.android.com/reference/android/app/Fragment#onDetach()() `

Called when the fragment is no longer attached to its activity.
` https://developer.android.com/reference/android/view/LayoutInflater` ` https://developer.android.com/reference/android/app/Fragment#onGetLayoutInflater(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Returns the LayoutInflater used to inflate Views of this Fragment.
` void` ` https://developer.android.com/reference/android/app/Fragment#onHiddenChanged(boolean)(boolean hidden) `

Called when the hidden state (as returned by `https://developer.android.com/reference/android/app/Fragment#isHidden()` of the fragment has changed.
` void` ` https://developer.android.com/reference/android/app/Fragment#onInflate(android.util.AttributeSet,%20android.os.Bundle)(https://developer.android.com/reference/android/util/AttributeSet attrs, https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

*This method was deprecated in API level 15. Use `https://developer.android.com/reference/android/app/Fragment#onInflate(android.content.Context,%20android.util.AttributeSet,%20android.os.Bundle)` instead.*
` void` ` https://developer.android.com/reference/android/app/Fragment#onInflate(android.app.Activity,%20android.util.AttributeSet,%20android.os.Bundle)(https://developer.android.com/reference/android/app/Activity activity, https://developer.android.com/reference/android/util/AttributeSet attrs, https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

*This method was deprecated in API level 23. Use `https://developer.android.com/reference/android/app/Fragment#onInflate(android.content.Context,%20android.util.AttributeSet,%20android.os.Bundle)` instead.*
` void` ` https://developer.android.com/reference/android/app/Fragment#onInflate(android.content.Context,%20android.util.AttributeSet,%20android.os.Bundle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/util/AttributeSet attrs, https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.
` void` ` https://developer.android.com/reference/android/app/Fragment#onLowMemory()() `

This is called when the overall system is running low on memory, and actively running processes should trim their memory usage. If you override this method you *must* call through to the superclass implementation.
` void` ` https://developer.android.com/reference/android/app/Fragment#onMultiWindowModeChanged(boolean)(boolean isInMultiWindowMode) `

*This method was deprecated in API level 26. Use `https://developer.android.com/reference/android/app/Fragment#onMultiWindowModeChanged(boolean,%20android.content.res.Configuration)` instead.*
` void` ` https://developer.android.com/reference/android/app/Fragment#onMultiWindowModeChanged(boolean,%20android.content.res.Configuration)(boolean isInMultiWindowMode, https://developer.android.com/reference/android/content/res/Configuration newConfig) `

Called when the Fragment's activity changes from fullscreen mode to multi-window mode and visa-versa.
` boolean` ` https://developer.android.com/reference/android/app/Fragment#onOptionsItemSelected(android.view.MenuItem)(https://developer.android.com/reference/android/view/MenuItem item) `

This hook is called whenever an item in your options menu is selected.
` void` ` https://developer.android.com/reference/android/app/Fragment#onOptionsMenuClosed(android.view.Menu)(https://developer.android.com/reference/android/view/Menu menu) `

This hook is called whenever the options menu is being closed (either by the user canceling the menu with the back/menu button, or when an item is selected).
` void` ` https://developer.android.com/reference/android/app/Fragment#onPause()() `

Called when the Fragment is no longer resumed.
` void` ` https://developer.android.com/reference/android/app/Fragment#onPictureInPictureModeChanged(boolean,%20android.content.res.Configuration)(boolean isInPictureInPictureMode, https://developer.android.com/reference/android/content/res/Configuration newConfig) `

Called by the system when the activity changes to and from picture-in-picture mode.
` void` ` https://developer.android.com/reference/android/app/Fragment#onPictureInPictureModeChanged(boolean)(boolean isInPictureInPictureMode) `

*This method was deprecated in API level 26. Use `https://developer.android.com/reference/android/app/Fragment#onPictureInPictureModeChanged(boolean,%20android.content.res.Configuration)` instead.*
` void` ` https://developer.android.com/reference/android/app/Fragment#onPrepareOptionsMenu(android.view.Menu)(https://developer.android.com/reference/android/view/Menu menu) `

Prepare the Screen's standard options menu to be displayed.
` void` ` https://developer.android.com/reference/android/app/Fragment#onRequestPermissionsResult(int,%20java.lang.String[],%20int[])(int requestCode, https://developer.android.com/reference/java/lang/String permissions, int[] grantResults) `

Callback for the result from requesting permissions.
` void` ` https://developer.android.com/reference/android/app/Fragment#onResume()() `

Called when the fragment is visible to the user and actively running.
` void` ` https://developer.android.com/reference/android/app/Fragment#onSaveInstanceState(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle outState) `

Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance of its process is restarted.
` void` ` https://developer.android.com/reference/android/app/Fragment#onStart()() `

Called when the Fragment is visible to the user.
` void` ` https://developer.android.com/reference/android/app/Fragment#onStop()() `

Called when the Fragment is no longer started.
` void` ` https://developer.android.com/reference/android/app/Fragment#onTrimMemory(int)(int level) `

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process. If you override this method you *must* call through to the superclass implementation.
` void` ` https://developer.android.com/reference/android/app/Fragment#onViewCreated(android.view.View,%20android.os.Bundle)(https://developer.android.com/reference/android/view/View view, https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Called immediately after `https://developer.android.com/reference/android/app/Fragment#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)` has returned, but before any saved state has been restored in to the view.
` void` ` https://developer.android.com/reference/android/app/Fragment#onViewStateRestored(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle savedInstanceState) `

Called when all saved state has been restored into the view hierarchy of the fragment.
` void` ` https://developer.android.com/reference/android/app/Fragment#postponeEnterTransition()() `

Postpone the entering Fragment transition until `https://developer.android.com/reference/android/app/Fragment#startPostponedEnterTransition()` or `https://developer.android.com/reference/android/app/FragmentManager#executePendingTransactions()` has been called.
` void` ` https://developer.android.com/reference/android/app/Fragment#registerForContextMenu(android.view.View)(https://developer.android.com/reference/android/view/View view) `

Registers a context menu to be shown for the given view (multiple views can show the context menu).
` final void` ` https://developer.android.com/reference/android/app/Fragment#requestPermissions(java.lang.String[],%20int)(https://developer.android.com/reference/java/lang/String permissions, int requestCode) `

Requests permissions to be granted to this application.
` void` ` https://developer.android.com/reference/android/app/Fragment#setAllowEnterTransitionOverlap(boolean)(boolean allow) `

Sets whether the exit transition and enter transition overlap or not.
` void` ` https://developer.android.com/reference/android/app/Fragment#setAllowReturnTransitionOverlap(boolean)(boolean allow) `

Sets whether the return transition and reenter transition overlap or not.
` void` ` https://developer.android.com/reference/android/app/Fragment#setArguments(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle args) `

Supply the construction arguments for this fragment.
` void` ` https://developer.android.com/reference/android/app/Fragment#setEnterSharedElementCallback(android.app.SharedElementCallback)(https://developer.android.com/reference/android/app/SharedElementCallback callback) `

When custom transitions are used with Fragments, the enter transition callback is called when this Fragment is attached or detached when not popping the back stack.
` void` ` https://developer.android.com/reference/android/app/Fragment#setEnterTransition(android.transition.Transition)(https://developer.android.com/reference/android/transition/Transition transition) `

Sets the Transition that will be used to move Views into the initial scene.
` void` ` https://developer.android.com/reference/android/app/Fragment#setExitSharedElementCallback(android.app.SharedElementCallback)(https://developer.android.com/reference/android/app/SharedElementCallback callback) `

When custom transitions are used with Fragments, the exit transition callback is called when this Fragment is attached or detached when popping the back stack.
` void` ` https://developer.android.com/reference/android/app/Fragment#setExitTransition(android.transition.Transition)(https://developer.android.com/reference/android/transition/Transition transition) `

Sets the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack.
` void` ` https://developer.android.com/reference/android/app/Fragment#setHasOptionsMenu(boolean)(boolean hasMenu) `

Report that this fragment would like to participate in populating the options menu by receiving a call to `https://developer.android.com/reference/android/app/Fragment#onCreateOptionsMenu(android.view.Menu,%20android.view.MenuInflater)` and related methods.
` void` ` https://developer.android.com/reference/android/app/Fragment#setInitialSavedState(android.app.Fragment.SavedState)(https://developer.android.com/reference/android/app/Fragment.SavedState state) `

Set the initial saved state that this Fragment should restore itself from when first being constructed, as returned by `https://developer.android.com/reference/android/app/FragmentManager#saveFragmentInstanceState(android.app.Fragment)`.
` void` ` https://developer.android.com/reference/android/app/Fragment#setMenuVisibility(boolean)(boolean menuVisible) `

Set a hint for whether this fragment's menu should be visible.
` void` ` https://developer.android.com/reference/android/app/Fragment#setReenterTransition(android.transition.Transition)(https://developer.android.com/reference/android/transition/Transition transition) `

Sets the Transition that will be used to move Views in to the scene when returning due to popping a back stack.
` void` ` https://developer.android.com/reference/android/app/Fragment#setRetainInstance(boolean)(boolean retain) `

Control whether a fragment instance is retained across Activity re-creation (such as from a configuration change).
` void` ` https://developer.android.com/reference/android/app/Fragment#setReturnTransition(android.transition.Transition)(https://developer.android.com/reference/android/transition/Transition transition) `

Sets the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack.
` void` ` https://developer.android.com/reference/android/app/Fragment#setSharedElementEnterTransition(android.transition.Transition)(https://developer.android.com/reference/android/transition/Transition transition) `

Sets the Transition that will be used for shared elements transferred into the content Scene.
` void` ` https://developer.android.com/reference/android/app/Fragment#setSharedElementReturnTransition(android.transition.Transition)(https://developer.android.com/reference/android/transition/Transition transition) `

Sets the Transition that will be used for shared elements transferred back during a pop of the back stack.
` void` ` https://developer.android.com/reference/android/app/Fragment#setTargetFragment(android.app.Fragment,%20int)(https://developer.android.com/reference/android/app/Fragment fragment, int requestCode) `

Optional target for this fragment.
` void` ` https://developer.android.com/reference/android/app/Fragment#setUserVisibleHint(boolean)(boolean isVisibleToUser) `

Set a hint to the system about whether this fragment's UI is currently visible to the user.
` boolean` ` https://developer.android.com/reference/android/app/Fragment#shouldShowRequestPermissionRationale(java.lang.String)(https://developer.android.com/reference/java/lang/String permission) `

Gets whether you should show UI with rationale before requesting a permission.
` void` ` https://developer.android.com/reference/android/app/Fragment#startActivity(android.content.Intent)(https://developer.android.com/reference/android/content/Intent intent) `

Call `https://developer.android.com/reference/android/app/Activity#startActivity(android.content.Intent)` from the fragment's containing Activity.
` void` ` https://developer.android.com/reference/android/app/Fragment#startActivity(android.content.Intent,%20android.os.Bundle)(https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/Bundle options) `

Call `https://developer.android.com/reference/android/app/Activity#startActivity(android.content.Intent,%20android.os.Bundle)` from the fragment's containing Activity.
` void` ` https://developer.android.com/reference/android/app/Fragment#startActivityForResult(android.content.Intent,%20int)(https://developer.android.com/reference/android/content/Intent intent, int requestCode) `

Call `https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)` from the fragment's containing Activity.
` void` ` https://developer.android.com/reference/android/app/Fragment#startActivityForResult(android.content.Intent,%20int,%20android.os.Bundle)(https://developer.android.com/reference/android/content/Intent intent, int requestCode, https://developer.android.com/reference/android/os/Bundle options) `

Call `https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int,%20android.os.Bundle)` from the fragment's containing Activity.
` void` ` https://developer.android.com/reference/android/app/Fragment#startIntentSenderForResult(android.content.IntentSender,%20int,%20android.content.Intent,%20int,%20int,%20int,%20android.os.Bundle)(https://developer.android.com/reference/android/content/IntentSender intent, int requestCode, https://developer.android.com/reference/android/content/Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, https://developer.android.com/reference/android/os/Bundle options) `

Call `https://developer.android.com/reference/android/app/Activity#startIntentSenderForResult(android.content.IntentSender,%20int,%20android.content.Intent,%20int,%20int,%20int,%20android.os.Bundle)` from the fragment's containing Activity.
` void` ` https://developer.android.com/reference/android/app/Fragment#startPostponedEnterTransition()() `

Begin postponed transitions after `https://developer.android.com/reference/android/app/Fragment#postponeEnterTransition()` was called.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/android/app/Fragment#toString()() `

Returns a string representation of the object.
` void` ` https://developer.android.com/reference/android/app/Fragment#unregisterForContextMenu(android.view.View)(https://developer.android.com/reference/android/view/View view) `

Prevents a context menu to be shown for the given view.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/android/content/ComponentCallbacks2 ` ` abstract void` ` https://developer.android.com/reference/android/content/ComponentCallbacks2#onTrimMemory(int)(int level) `

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process.
From interface ` https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener ` ` abstract void` ` https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener#onCreateContextMenu(android.view.ContextMenu,%20android.view.View,%20android.view.ContextMenu.ContextMenuInfo)(https://developer.android.com/reference/android/view/ContextMenu menu, https://developer.android.com/reference/android/view/View v, https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo menuInfo) `

Called when the context menu for this view is being built.
From interface ` https://developer.android.com/reference/android/content/ComponentCallbacks ` ` abstract void` ` https://developer.android.com/reference/android/content/ComponentCallbacks#onConfigurationChanged(android.content.res.Configuration)(https://developer.android.com/reference/android/content/res/Configuration newConfig) `

Called by the system when the device configuration changes while your component is running.
` abstract void` ` https://developer.android.com/reference/android/content/ComponentCallbacks#onLowMemory()() `

*This method was deprecated in API level 35. Since API level 14 this is superseded by `https://developer.android.com/reference/android/content/ComponentCallbacks2#onTrimMemory(int)`. Since API level 34 this is never called. If you're overriding ComponentCallbacks2#onTrimMemory and your minSdkVersion is greater than API 14, you can provide an empty implementation for this method.*

## Public constructors

### ListFragment

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ListFragment ()
```

<br />

<br />

## Public methods

### getListAdapter

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ListAdapter getListAdapter ()
```

Get the ListAdapter associated with this fragment's ListView.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/widget/ListAdapter` | <br /> |

### getListView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ListView getListView ()
```

Get the fragment's list view widget.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/widget/ListView` | <br /> |

### getSelectedItemId

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getSelectedItemId ()
```

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

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getSelectedItemPosition

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSelectedItemPosition ()
```

Get the position of the currently selected list item.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### onCreateView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View onCreateView (LayoutInflater inflater, 
                ViewGroup container, 
                Bundle savedInstanceState)
```

Provide default implementation to return a simple list view. Subclasses can override to replace with their own layout. If doing so, the returned view hierarchy *must* have a ListView whose id is `https://developer.android.com/reference/android/R.id#list` and can optionally have a sibling view id `https://developer.android.com/reference/android/R.id#empty` that is to be shown when the list is empty.

If you are overriding this method with your own custom content, consider including the standard layout `https://developer.android.com/reference/android/R.layout#list_content` in your layout file, so that you continue to retain all of the standard behavior of ListFragment. In particular, this is currently the only way to have the built-in indeterminant progress state be shown.

<br />

| Parameters ||
|---|---|
| `inflater` | `LayoutInflater`: The LayoutInflater object that can be used to inflate any views in the fragment, <br /> |
| `container` | `ViewGroup`: If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view. <br /> |
| `savedInstanceState` | `Bundle`: If non-null, this fragment is being re-constructed from a previous saved state as given here. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | Return the View for the fragment's UI, or null. <br /> |

### onDestroyView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onDestroyView ()
```

Detach from list view.

<br />

### onListItemClick

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onListItemClick (ListView l, 
                View v, 
                int position, 
                long id)
```

This method will be called when an item in the list is selected. Subclasses should override. Subclasses can call getListView().getItemAtPosition(position) if they need to access the data associated with the selected item.

<br />

| Parameters ||
|---|---|
| `l` | `ListView`: The ListView where the click happened <br /> |
| `v` | `View`: The view that was clicked within the ListView <br /> |
| `position` | `int`: The position of the view in the list <br /> |
| `id` | `long`: The row id of the item that was clicked <br /> |

### onViewCreated

Added in [API level 13](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onViewCreated (View view, 
                Bundle savedInstanceState)
```

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

<br />

| Parameters ||
|---|---|
| `view` | `View`: The View returned by `https://developer.android.com/reference/android/app/ListFragment#onCreateView(android.view.LayoutInflater,%20android.view.ViewGroup,%20android.os.Bundle)`. <br /> |
| `savedInstanceState` | `Bundle`: If non-null, this fragment is being re-constructed from a previous saved state as given here. <br /> |

### setEmptyText

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setEmptyText (CharSequence text)
```

The default content for a ListFragment has a TextView that can be shown when the list is empty. If you would like to have it shown, call this method to supply the text it should use.

<br />

| Parameters ||
|---|---|
| `text` | `CharSequence` <br /> |

### setListAdapter

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setListAdapter (ListAdapter adapter)
```

Provide the cursor for the list view.

<br />

| Parameters ||
|---|---|
| `adapter` | `ListAdapter` <br /> |

### setListShown

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setListShown (boolean shown)
```

Control whether the list is being displayed. You can make it not displayed if you are waiting for the initial data to show in it. During this time an indeterminant progress indicator will be shown instead.

Applications do not normally need to use this themselves. The default behavior of ListFragment is to start with the list not being shown, only showing it once an adapter is given with `https://developer.android.com/reference/android/app/ListFragment#setListAdapter(android.widget.ListAdapter)`. If the list at that point had not been shown, when it does get shown it will be do without the user ever seeing the hidden state.

<br />

| Parameters ||
|---|---|
| `shown` | `boolean`: If true, the list view is shown; if false, the progress indicator. The initial value is true. <br /> |

### setListShownNoAnimation

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setListShownNoAnimation (boolean shown)
```

Like `https://developer.android.com/reference/android/app/ListFragment#setListShown(boolean)`, but no animation is used when transitioning from the previous state.

<br />

| Parameters ||
|---|---|
| `shown` | `boolean` <br /> |

### setSelection

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setSelection (int position)
```

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

<br />