# ListPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:preference-v7:28.0.0-alpha1  
Summary:[Inherited XML Attrs](https://developer.android.com/reference/android/support/v7/preference/ListPreference#inhattrs)\|[Inherited Constants](https://developer.android.com/reference/android/support/v7/preference/ListPreference#inhconstants)\|[Ctors](https://developer.android.com/reference/android/support/v7/preference/ListPreference#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v7/preference/ListPreference#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/v7/preference/ListPreference#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/preference/ListPreference#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/preference/ListPreference#)  

# ListPreference

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
ListPreference
`  
`


``


``

extends `[DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference)`


``


`

|---|---|---|----------------------------------------------|
| java.lang.Object                                      ||||
| ↳ | [android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference) |||
|   | ↳ | [android.support.v7.preference.DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference) ||
|   |   | ↳ | android.support.v7.preference.ListPreference |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/ListPreference#)Known Direct Subclasses [DropDownPreference](https://developer.android.com/reference/android/support/v7/preference/DropDownPreference) |----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [DropDownPreference](https://developer.android.com/reference/android/support/v7/preference/DropDownPreference) | A version of[ListPreference](https://developer.android.com/reference/android/support/v7/preference/ListPreference)that presents the options in a drop down menu rather than a dialog. | |

<br />

*** ** * ** ***

A[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)that displays a list of entries as a dialog.

This preference will store a string into the SharedPreferences. This string will be the value from the[setEntryValues(CharSequence[])](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntryValues(java.lang.CharSequence[]))array.

## Summary

| ### Inherited XML attributes |
|------------------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/ListPreference#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |----------------------------------------------------------------------------------------------------------------------------------------------------------------------|---| | [`Preference_android_iconSpaceReserved`](https://developer.android.com/reference/android/support/v7/preference/Preference#attr_Preference_android_iconSpaceReserved) |   | | [`Preference_android_singleLineTitle`](https://developer.android.com/reference/android/support/v7/preference/Preference#attr_Preference_android_singleLineTitle)     |   | ||

|                                                                                                                                                                                                                                                                                                                                                                                                                                            ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/ListPreference#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [DEFAULT_ORDER](https://developer.android.com/reference/android/support/v7/preference/Preference#DEFAULT_ORDER) Specify for[setOrder(int)](https://developer.android.com/reference/android/support/v7/preference/Preference#setOrder(int))if a specific order is not required. | |

|                                                                                                                                                                                                  ### Public constructors                                                                                                                                                                                                   ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[ListPreference](https://developer.android.com/reference/android/support/v7/preference/ListPreference#ListPreference(android.content.Context, android.util.AttributeSet, int, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs, int defStyleAttr, int defStyleRes) ` |
| ` `[ListPreference](https://developer.android.com/reference/android/support/v7/preference/ListPreference#ListPreference(android.content.Context, android.util.AttributeSet, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs, int defStyleAttr) `                       |
| ` `[ListPreference](https://developer.android.com/reference/android/support/v7/preference/ListPreference#ListPreference(android.content.Context, android.util.AttributeSet))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs) `                                              |
| ` `[ListPreference](https://developer.android.com/reference/android/support/v7/preference/ListPreference#ListPreference(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) `                                                                                                                                                                         |

|                                                                                                                                        ### Public methods                                                                                                                                         ||
|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` int`            | ` `[findIndexOfValue](https://developer.android.com/reference/android/support/v7/preference/ListPreference#findIndexOfValue(java.lang.String))`(String value) ` Returns the index of the given value (in the entry values array).                                              |
| ` CharSequence[]` | ` `[getEntries](https://developer.android.com/reference/android/support/v7/preference/ListPreference#getEntries())`() ` The list of entries to be shown in the list in subsequent dialogs.                                                                                     |
| ` CharSequence`   | ` `[getEntry](https://developer.android.com/reference/android/support/v7/preference/ListPreference#getEntry())`() ` Returns the entry corresponding to the current value.                                                                                                      |
| ` CharSequence[]` | ` `[getEntryValues](https://developer.android.com/reference/android/support/v7/preference/ListPreference#getEntryValues())`() ` Returns the array of values to be saved for the preference.                                                                                    |
| ` CharSequence`   | ` `[getSummary](https://developer.android.com/reference/android/support/v7/preference/ListPreference#getSummary())`() ` Returns the summary of this ListPreference.                                                                                                            |
| ` String`         | ` `[getValue](https://developer.android.com/reference/android/support/v7/preference/ListPreference#getValue())`() ` Returns the value of the key.                                                                                                                              |
| ` void`           | ` `[setEntries](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntries(java.lang.CharSequence[]))`(CharSequence[] entries) ` Sets the human-readable entries to be shown in the list.                                                 |
| ` void`           | ` `[setEntries](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntries(int))`(int entriesResId) `                                                                                                                                     |
| ` void`           | ` `[setEntryValues](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntryValues(int))`(int entryValuesResId) `                                                                                                                         |
| ` void`           | ` `[setEntryValues](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntryValues(java.lang.CharSequence[]))`(CharSequence[] entryValues) ` The array to find the value to save for a preference when an entry from entries is selected. |
| ` void`           | ` `[setSummary](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setSummary(java.lang.CharSequence))`(CharSequence summary) ` Sets the summary for this Preference with a CharSequence.                                                    |
| ` void`           | ` `[setValue](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setValue(java.lang.String))`(String value) ` Sets the value of the key.                                                                                                     |
| ` void`           | ` `[setValueIndex](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setValueIndex(int))`(int index) ` Sets the value to the given index from the entry values.                                                                             |

|                                                                                                                                                                                                                                                                                         ### Protected methods                                                                                                                                                                                                                                                                                         ||
|-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` Object`                                                                           | ` `[onGetDefaultValue](https://developer.android.com/reference/android/support/v7/preference/ListPreference#onGetDefaultValue(android.content.res.TypedArray, int))`(`[TypedArray](https://developer.android.com/reference/android/content/res/TypedArray.html)` a, int index) ` Called when a Preference is being inflated and the default value attribute needs to be read.                                                                                                                                    |
| ` void`                                                                             | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/support/v7/preference/ListPreference#onRestoreInstanceState(android.os.Parcelable))`(`[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state) ` Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState()). |
| ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) | ` `[onSaveInstanceState](https://developer.android.com/reference/android/support/v7/preference/ListPreference#onSaveInstanceState())`() ` Hook allowing a Preference to generate a representation of its internal state that can later be used to create a new instance with that same state.                                                                                                                                                                                                                    |
| ` void`                                                                             | ` `[onSetInitialValue](https://developer.android.com/reference/android/support/v7/preference/ListPreference#onSetInitialValue(boolean, java.lang.Object))`(boolean restoreValue, Object defaultValue) ` Implement this to set the initial value of the Preference.                                                                                                                                                                                                                                               |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/ListPreference#)From class` `[android.support.v7.preference.DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference)` ` |------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html) | ` `[getDialogIcon](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getDialogIcon())`() ` Returns the icon to be shown on subsequent dialogs.                                                                                                                                                                      | | ` int`                                                                                         | ` `[getDialogLayoutResource](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getDialogLayoutResource())`() ` Returns the layout resource that is used as the content View for subsequent dialogs.                                                                                                                 | | ` CharSequence`                                                                                | ` `[getDialogMessage](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getDialogMessage())`() ` Returns the message to be shown on subsequent dialogs.                                                                                                                                                             | | ` CharSequence`                                                                                | ` `[getDialogTitle](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getDialogTitle())`() ` Returns the title to be shown on subsequent dialogs.                                                                                                                                                                   | | ` CharSequence`                                                                                | ` `[getNegativeButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getNegativeButtonText())`() ` Returns the text of the negative button to be shown on subsequent dialogs.                                                                                                                               | | ` CharSequence`                                                                                | ` `[getPositiveButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#getPositiveButtonText())`() ` Returns the text of the positive button to be shown on subsequent dialogs.                                                                                                                               | | ` void`                                                                                        | ` `[onClick](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#onClick())`() ` Processes a click on the preference.                                                                                                                                                                                                 | | ` void`                                                                                        | ` `[setDialogIcon](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogIcon(int))`(int dialogIconRes) ` Sets the icon (resource ID) of the dialog.                                                                                                                                                           | | ` void`                                                                                        | ` `[setDialogIcon](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` dialogIcon) ` Sets the icon of the dialog.                                                   | | ` void`                                                                                        | ` `[setDialogLayoutResource](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogLayoutResource(int))`(int dialogLayoutResId) ` Sets the layout resource that is inflated as the[View](https://developer.android.com/reference/android/view/View.html)to be shown as the content View of subsequent dialogs. | | ` void`                                                                                        | ` `[setDialogMessage](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogMessage(java.lang.CharSequence))`(CharSequence dialogMessage) ` Sets the message of the dialog.                                                                                                                                    | | ` void`                                                                                        | ` `[setDialogMessage](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogMessage(int))`(int dialogMessageResId) `                                                                                                                                                                                           | | ` void`                                                                                        | ` `[setDialogTitle](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogTitle(int))`(int dialogTitleResId) `                                                                                                                                                                                                 | | ` void`                                                                                        | ` `[setDialogTitle](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setDialogTitle(java.lang.CharSequence))`(CharSequence dialogTitle) ` Sets the title of the dialog.                                                                                                                                            | | ` void`                                                                                        | ` `[setNegativeButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setNegativeButtonText(java.lang.CharSequence))`(CharSequence negativeButtonText) ` Sets the text of the negative button of the dialog.                                                                                                 | | ` void`                                                                                        | ` `[setNegativeButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setNegativeButtonText(int))`(int negativeButtonTextResId) `                                                                                                                                                                            | | ` void`                                                                                        | ` `[setPositiveButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setPositiveButtonText(int))`(int positiveButtonTextResId) `                                                                                                                                                                            | | ` void`                                                                                        | ` `[setPositiveButtonText](https://developer.android.com/reference/android/support/v7/preference/DialogPreference#setPositiveButtonText(java.lang.CharSequence))`(CharSequence positiveButtonText) ` Sets the text of the positive button of the dialog.                                                                                                 | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/ListPreference#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |---------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` boolean`                                                                                                                                              | ` `[callChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#callChangeListener(java.lang.Object))`(Object newValue) ` Call this method after the user changes the preference, but before the internal state is set.                                                                                                                                                                                                                                                                                                                                  | | ` int`                                                                                                                                                  | ` `[compareTo](https://developer.android.com/reference/android/support/v7/preference/Preference#compareTo(android.support.v7.preference.Preference))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` another) ` Compares Preference objects based on order (if set), otherwise alphabetically on the titles.                                                                                                                                                                                                                                    | | ` `[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)                                                       | ` `[findPreferenceInHierarchy](https://developer.android.com/reference/android/support/v7/preference/Preference#findPreferenceInHierarchy(java.lang.String))`(String key) ` Finds a Preference in this hierarchy (the whole thing, even above/below your[PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)screen break) with the given key.                                                                                                                                                                                               | | ` `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                      | ` `[getContext](https://developer.android.com/reference/android/support/v7/preference/Preference#getContext())`() ` Returns the[Context](https://developer.android.com/reference/android/content/Context.html)of this Preference.                                                                                                                                                                                                                                                                                                                                                                 | | ` String`                                                                                                                                               | ` `[getDependency](https://developer.android.com/reference/android/support/v7/preference/Preference#getDependency())`() ` Returns the key of the dependency on this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                             | ` `[getExtras](https://developer.android.com/reference/android/support/v7/preference/Preference#getExtras())`() ` Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one.                                                                                                                                                                                                                                                                                                                                                            | | ` String`                                                                                                                                               | ` `[getFragment](https://developer.android.com/reference/android/support/v7/preference/Preference#getFragment())`() ` Return the fragment class name associated with this Preference.                                                                                                                                                                                                                                                                                                                                                                                                             | | ` `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)                                                          | ` `[getIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#getIcon())`() ` Returns the icon of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` `[Intent](https://developer.android.com/reference/android/content/Intent.html)                                                                        | ` `[getIntent](https://developer.android.com/reference/android/support/v7/preference/Preference#getIntent())`() ` Return the[Intent](https://developer.android.com/reference/android/content/Intent.html)associated with this Preference.                                                                                                                                                                                                                                                                                                                                                         | | ` String`                                                                                                                                               | ` `[getKey](https://developer.android.com/reference/android/support/v7/preference/Preference#getKey())`() ` Gets the key for this Preference, which is also the key used for storing values into[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore).                                                                                                                                                                            | | ` final int`                                                                                                                                            | ` `[getLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#getLayoutResource())`() ` Gets the layout resource that will be shown as the[View](https://developer.android.com/reference/android/view/View.html)for this Preference.                                                                                                                                                                                                                                                                                                                    | | ` `[Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceChangeListener) | ` `[getOnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#getOnPreferenceChangeListener())`() ` Returns the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).                                                                                                                                                                                                                                                                                                        | | ` `[Preference.OnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)   | ` `[getOnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference#getOnPreferenceClickListener())`() ` Returns the callback to be invoked when this Preference is clicked.                                                                                                                                                                                                                                                                                                                                                                       | | ` int`                                                                                                                                                  | ` `[getOrder](https://developer.android.com/reference/android/support/v7/preference/Preference#getOrder())`() ` Gets the order of this Preference with respect to other Preference objects on the same level.                                                                                                                                                                                                                                                                                                                                                                                     | | ` `[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)                                             | ` `[getParent](https://developer.android.com/reference/android/support/v7/preference/Preference#getParent())`() ` Returns the[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)which is this Preference assigned to or null if this preference is not assigned to any group or is a root Preference.                                                                                                                                                                                                                                        | | ` boolean`                                                                                                                                              | ` `[getPersistedBoolean](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedBoolean(boolean))`(boolean defaultReturnValue) ` Attempts to get a persisted[Boolean](https://developer.android.com/reference/java/lang/Boolean)if this Preference is persistent.                                                                                                                                                                                                                                                                                           | | ` float`                                                                                                                                                | ` `[getPersistedFloat](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedFloat(float))`(float defaultReturnValue) ` Attempts to get a persisted[Float](https://developer.android.com/reference/java/lang/Float)if this Preference is persistent.                                                                                                                                                                                                                                                                                                       | | ` int`                                                                                                                                                  | ` `[getPersistedInt](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedInt(int))`(int defaultReturnValue) ` Attempts to get a persisted[Integer](https://developer.android.com/reference/java/lang/Integer)if this Preference is persistent.                                                                                                                                                                                                                                                                                                           | | ` long`                                                                                                                                                 | ` `[getPersistedLong](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedLong(long))`(long defaultReturnValue) ` Attempts to get a persisted[Long](https://developer.android.com/reference/java/lang/Long)if this Preference is persistent.                                                                                                                                                                                                                                                                                                             | | ` String`                                                                                                                                               | ` `[getPersistedString](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedString(java.lang.String))`(String defaultReturnValue) ` Attempts to get a persisted set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                         | | ` Set<String>`                                                                                                                                          | ` `[getPersistedStringSet](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedStringSet(java.util.Set<java.lang.String>))`(Set<String> defaultReturnValue) ` Attempts to get a persisted set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                               | | ` `[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)                                     | ` `[getPreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/Preference#getPreferenceDataStore())`() ` Returns[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)used by this Preference.                                                                                                                                                                                                                                                                                                       | | ` `[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)                                         | ` `[getPreferenceManager](https://developer.android.com/reference/android/support/v7/preference/Preference#getPreferenceManager())`() ` Gets the[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)that manages this Preference object's tree.                                                                                                                                                                                                                                                                                           | | ` `[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)                                                  | ` `[getSharedPreferences](https://developer.android.com/reference/android/support/v7/preference/Preference#getSharedPreferences())`() ` Returns the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)where this Preference can read its value(s).                                                                                                                                                                                                                                                                                                | | ` boolean`                                                                                                                                              | ` `[getShouldDisableView](https://developer.android.com/reference/android/support/v7/preference/Preference#getShouldDisableView())`() ` Checks whether this Preference should disable its view when it's action is disabled.                                                                                                                                                                                                                                                                                                                                                                      | | ` CharSequence`                                                                                                                                         | ` `[getSummary](https://developer.android.com/reference/android/support/v7/preference/Preference#getSummary())`() ` Returns the summary of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` CharSequence`                                                                                                                                         | ` `[getTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#getTitle())`() ` Returns the title of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` final int`                                                                                                                                            | ` `[getWidgetLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#getWidgetLayoutResource())`() ` Gets the layout resource for the controllable widget portion of this Preference.                                                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[hasKey](https://developer.android.com/reference/android/support/v7/preference/Preference#hasKey())`() ` Checks whether this Preference has a valid key.                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                                                                              | ` `[isEnabled](https://developer.android.com/reference/android/support/v7/preference/Preference#isEnabled())`() ` Checks whether this Preference should be enabled in the list.                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` boolean`                                                                                                                                              | ` `[isIconSpaceReserved](https://developer.android.com/reference/android/support/v7/preference/Preference#isIconSpaceReserved())`() ` Returns whether the space of this preference icon view is reserved.                                                                                                                                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                                                                              | ` `[isPersistent](https://developer.android.com/reference/android/support/v7/preference/Preference#isPersistent())`() ` Checks whether this Preference is persistent.                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` boolean`                                                                                                                                              | ` `[isSelectable](https://developer.android.com/reference/android/support/v7/preference/Preference#isSelectable())`() ` Checks whether this Preference should be selectable in the list.                                                                                                                                                                                                                                                                                                                                                                                                          | | ` boolean`                                                                                                                                              | ` `[isSingleLineTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#isSingleLineTitle())`() ` Gets whether the title of this preference is constrained to a single line.                                                                                                                                                                                                                                                                                                                                                                                      | | ` final boolean`                                                                                                                                        | ` `[isVisible](https://developer.android.com/reference/android/support/v7/preference/Preference#isVisible())`() ` Checks whether this preference should be visible to the user in the list.                                                                                                                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                                                                                 | ` `[notifyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyChanged())`() ` Should be called when the data of this[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)has changed.                                                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                                                                 | ` `[notifyDependencyChange](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyDependencyChange(boolean))`(boolean disableDependents) ` Notifies any listening dependents of a change that affects the dependency.                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[notifyHierarchyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyHierarchyChanged())`() ` Should be called when a Preference has been added/removed from this group, or the ordering should be re-evaluated.                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[onAttached](https://developer.android.com/reference/android/support/v7/preference/Preference#onAttached())`() ` Called when the Preference hierarchy has been attached to the list of preferences.                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[onAttachedToHierarchy](https://developer.android.com/reference/android/support/v7/preference/Preference#onAttachedToHierarchy(android.support.v7.preference.PreferenceManager))`(`[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)` preferenceManager) ` Called when this Preference has been attached to a Preference hierarchy.                                                                                                                                                                                                 | | ` void`                                                                                                                                                 | ` `[onBindViewHolder](https://developer.android.com/reference/android/support/v7/preference/Preference#onBindViewHolder(android.support.v7.preference.PreferenceViewHolder))`(`[PreferenceViewHolder](https://developer.android.com/reference/android/support/v7/preference/PreferenceViewHolder)` holder) ` Binds the created View to the data for this Preference.                                                                                                                                                                                                                              | | ` void`                                                                                                                                                 | ` `[onClick](https://developer.android.com/reference/android/support/v7/preference/Preference#onClick())`() ` Processes a click on the preference.                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                                 | ` `[onDependencyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#onDependencyChanged(android.support.v7.preference.Preference, boolean))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` dependency, boolean disableDependent) ` Called when the dependency changes.                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[onDetached](https://developer.android.com/reference/android/support/v7/preference/Preference#onDetached())`() ` Called when the Preference hierarchy has been detached from the list of preferences.                                                                                                                                                                                                                                                                                                                                                                                          | | ` Object`                                                                                                                                               | ` `[onGetDefaultValue](https://developer.android.com/reference/android/support/v7/preference/Preference#onGetDefaultValue(android.content.res.TypedArray, int))`(`[TypedArray](https://developer.android.com/reference/android/content/res/TypedArray.html)` a, int index) ` Called when a Preference is being inflated and the default value attribute needs to be read.                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[onInitializeAccessibilityNodeInfo](https://developer.android.com/reference/android/support/v7/preference/Preference#onInitializeAccessibilityNodeInfo(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat))`(`[AccessibilityNodeInfoCompat](https://developer.android.com/reference/android/support/v4/view/accessibility/AccessibilityNodeInfoCompat)` info) ` Initializes an[AccessibilityNodeInfo](https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html)with information about the View for this Preference.                        | | ` void`                                                                                                                                                 | ` `[onParentChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#onParentChanged(android.support.v7.preference.Preference, boolean))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` parent, boolean disableChild) ` Called when the implicit parent dependency changes.                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[onPrepareForRemoval](https://developer.android.com/reference/android/support/v7/preference/Preference#onPrepareForRemoval())`() ` Called when this Preference is being removed from the hierarchy.                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/support/v7/preference/Preference#onRestoreInstanceState(android.os.Parcelable))`(`[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state) ` Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState()).                                                                                      | | ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)                                                                     | ` `[onSaveInstanceState](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState())`() ` Hook allowing a Preference to generate a representation of its internal state that can later be used to create a new instance with that same state.                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[onSetInitialValue](https://developer.android.com/reference/android/support/v7/preference/Preference#onSetInitialValue(boolean, java.lang.Object))`(boolean restorePersistedValue, Object defaultValue) ` Implement this to set the initial value of the Preference.                                                                                                                                                                                                                                                                                                                           | | ` `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                             | ` `[peekExtras](https://developer.android.com/reference/android/support/v7/preference/Preference#peekExtras())`() ` Return the extras Bundle object associated with this preference, returning null if there is not currently one.                                                                                                                                                                                                                                                                                                                                                                | | ` boolean`                                                                                                                                              | ` `[persistBoolean](https://developer.android.com/reference/android/support/v7/preference/Preference#persistBoolean(boolean))`(boolean value) ` Attempts to persist a[Boolean](https://developer.android.com/reference/java/lang/Boolean)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                                                                                              | ` `[persistFloat](https://developer.android.com/reference/android/support/v7/preference/Preference#persistFloat(float))`(float value) ` Attempts to persist a[Float](https://developer.android.com/reference/java/lang/Float)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[persistInt](https://developer.android.com/reference/android/support/v7/preference/Preference#persistInt(int))`(int value) ` Attempts to persist an[Integer](https://developer.android.com/reference/java/lang/Integer)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                                                                              | ` `[persistLong](https://developer.android.com/reference/android/support/v7/preference/Preference#persistLong(long))`(long value) ` Attempts to persist a[Long](https://developer.android.com/reference/java/lang/Long)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                          | | ` boolean`                                                                                                                                              | ` `[persistString](https://developer.android.com/reference/android/support/v7/preference/Preference#persistString(java.lang.String))`(String value) ` Attempts to persist a[String](https://developer.android.com/reference/java/lang/String)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[persistStringSet](https://developer.android.com/reference/android/support/v7/preference/Preference#persistStringSet(java.util.Set<java.lang.String>))`(Set<String> values) ` Attempts to persist a set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[restoreHierarchyState](https://developer.android.com/reference/android/support/v7/preference/Preference#restoreHierarchyState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` container) ` Restore this Preference hierarchy's previously saved state from the given container.                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[saveHierarchyState](https://developer.android.com/reference/android/support/v7/preference/Preference#saveHierarchyState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` container) ` Store this Preference hierarchy's frozen state into the given container.                                                                                                                                                                                                                                                                                 | | ` void`                                                                                                                                                 | ` `[setDefaultValue](https://developer.android.com/reference/android/support/v7/preference/Preference#setDefaultValue(java.lang.Object))`(Object defaultValue) ` Sets the default value for this Preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.                                                                                                                                                                                                                                                       | | ` void`                                                                                                                                                 | ` `[setDependency](https://developer.android.com/reference/android/support/v7/preference/Preference#setDependency(java.lang.String))`(String dependencyKey) ` Sets the key of a Preference that this Preference will depend on.                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setEnabled](https://developer.android.com/reference/android/support/v7/preference/Preference#setEnabled(boolean))`(boolean enabled) ` Sets whether this Preference is enabled.                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                                 | ` `[setFragment](https://developer.android.com/reference/android/support/v7/preference/Preference#setFragment(java.lang.String))`(String fragment) ` Sets the class name of a fragment to be shown when this Preference is clicked.                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#setIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` icon) ` Sets the icon for this Preference with a Drawable.                                                                                                                                                                                                                                                                                              | | ` void`                                                                                                                                                 | ` `[setIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#setIcon(int))`(int iconResId) ` Sets the icon for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setIconSpaceReserved](https://developer.android.com/reference/android/support/v7/preference/Preference#setIconSpaceReserved(boolean))`(boolean iconSpaceReserved) ` Sets whether to reserve the space of this Preference icon view when no icon is provided.                                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                                                                                 | ` `[setIntent](https://developer.android.com/reference/android/support/v7/preference/Preference#setIntent(android.content.Intent))`(`[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` Sets an[Intent](https://developer.android.com/reference/android/content/Intent.html)to be used for[startActivity(Intent)](https://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent))when this Preference is clicked.                                                                                               | | ` void`                                                                                                                                                 | ` `[setKey](https://developer.android.com/reference/android/support/v7/preference/Preference#setKey(java.lang.String))`(String key) ` Sets the key for this Preference, which is used as a key to the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore).                                                                                                                                                                       | | ` void`                                                                                                                                                 | ` `[setLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#setLayoutResource(int))`(int layoutResId) ` Sets the layout resource that is inflated as the[View](https://developer.android.com/reference/android/view/View.html)to be shown for this Preference.                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                                                                 | ` `[setOnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#setOnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener))`(`[Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceChangeListener)` onPreferenceChangeListener) ` Sets the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).                                                       | | ` void`                                                                                                                                                 | ` `[setOnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference#setOnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener))`(`[Preference.OnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)` onPreferenceClickListener) ` Sets the callback to be invoked when this Preference is clicked.                                                                                                                          | | ` void`                                                                                                                                                 | ` `[setOrder](https://developer.android.com/reference/android/support/v7/preference/Preference#setOrder(int))`(int order) ` Sets the order of this Preference with respect to other Preference objects on the same level.                                                                                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[setPersistent](https://developer.android.com/reference/android/support/v7/preference/Preference#setPersistent(boolean))`(boolean persistent) ` Sets whether this Preference is persistent.                                                                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[setPreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/Preference#setPreferenceDataStore(android.support.v7.preference.PreferenceDataStore))`(`[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)` dataStore) ` Sets a[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)to be used by this Preference instead of using[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html). | | ` void`                                                                                                                                                 | ` `[setSelectable](https://developer.android.com/reference/android/support/v7/preference/Preference#setSelectable(boolean))`(boolean selectable) ` Sets whether this Preference is selectable.                                                                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[setShouldDisableView](https://developer.android.com/reference/android/support/v7/preference/Preference#setShouldDisableView(boolean))`(boolean shouldDisableView) ` Sets whether this Preference should disable its view when it gets disabled.                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setSingleLineTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setSingleLineTitle(boolean))`(boolean singleLineTitle) ` Sets whether to constrain the title of this Preference to a single line instead of letting it wrap onto multiple lines.                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[setSummary](https://developer.android.com/reference/android/support/v7/preference/Preference#setSummary(java.lang.CharSequence))`(CharSequence summary) ` Sets the summary for this Preference with a CharSequence.                                                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[setSummary](https://developer.android.com/reference/android/support/v7/preference/Preference#setSummary(int))`(int summaryResId) ` Sets the summary for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setTitle(java.lang.CharSequence))`(CharSequence title) ` Sets the title for this Preference with a CharSequence.                                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setTitle(int))`(int titleResId) ` Sets the title for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[setViewId](https://developer.android.com/reference/android/support/v7/preference/Preference#setViewId(int))`(int viewId) ` Set the ID that will be assigned to the overall View representing this preference, once bound.                                                                                                                                                                                                                                                                                                                                                                     | | ` final void`                                                                                                                                           | ` `[setVisible](https://developer.android.com/reference/android/support/v7/preference/Preference#setVisible(boolean))`(boolean visible) ` Sets whether this preference should be visible in the list.                                                                                                                                                                                                                                                                                                                                                                                             | | ` void`                                                                                                                                                 | ` `[setWidgetLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#setWidgetLayoutResource(int))`(int widgetLayoutResId) ` Sets the layout for the controllable widget portion of this Preference.                                                                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                                                                              | ` `[shouldDisableDependents](https://developer.android.com/reference/android/support/v7/preference/Preference#shouldDisableDependents())`() ` Checks whether this preference's dependents should currently be disabled.                                                                                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                                                                              | ` `[shouldPersist](https://developer.android.com/reference/android/support/v7/preference/Preference#shouldPersist())`() ` Checks whether, at the given time this method is called, this Preference should store/restore its value(s) into the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or into[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)if assigned.                                                                                                               | | ` String`                                                                                                                                               | ` `[toString](https://developer.android.com/reference/android/support/v7/preference/Preference#toString())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/ListPreference#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/ListPreference#)From interface` java.lang.Comparable ` |-----------------|----------------------------------------------------------------------------------------------------------------------| | ` abstract int` | ` compareTo(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` arg0) ` | ||

## Public constructors

### ListPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ListPreference (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)
```

<br />

<br />

|              Parameters               ||
|----------------|-----------------------|
| `context`      | `Context` <br />      |
| `attrs`        | `AttributeSet` <br /> |
| `defStyleAttr` | `int` <br />          |
| `defStyleRes`  | `int` <br />          |

### ListPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ListPreference (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)
```

<br />

<br />

|              Parameters               ||
|----------------|-----------------------|
| `context`      | `Context` <br />      |
| `attrs`        | `AttributeSet` <br /> |
| `defStyleAttr` | `int` <br />          |

### ListPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ListPreference (Context context, 
                AttributeSet attrs)
```

<br />

<br />

|            Parameters            ||
|-----------|-----------------------|
| `context` | `Context` <br />      |
| `attrs`   | `AttributeSet` <br /> |

### ListPreference

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
ListPreference (Context context)
```

<br />

<br />

|         Parameters          ||
|-----------|------------------|
| `context` | `Context` <br /> |

## Public methods

### findIndexOfValue

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int findIndexOfValue (String value)
```

Returns the index of the given value (in the entry values array).

<br />

|                             Parameters                              ||
|---------|------------------------------------------------------------|
| `value` | `String`: The value whose index should be returned. <br /> |

|                          Returns                          ||
|-------|----------------------------------------------------|
| `int` | The index of the value, or -1 if not found. <br /> |

### getEntries

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CharSequence[] getEntries ()
```

The list of entries to be shown in the list in subsequent dialogs.

<br />

|                    Returns                     ||
|------------------|------------------------------|
| `CharSequence[]` | The list as an array. <br /> |

### getEntry

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CharSequence getEntry ()
```

Returns the entry corresponding to the current value.

<br />

|                                    Returns                                    ||
|----------------|---------------------------------------------------------------|
| `CharSequence` | The entry corresponding to the current value, or null. <br /> |

### getEntryValues

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CharSequence[] getEntryValues ()
```

Returns the array of values to be saved for the preference.

<br />

|                    Returns                    ||
|------------------|-----------------------------|
| `CharSequence[]` | The array of values. <br /> |

### getSummary

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
CharSequence getSummary ()
```

Returns the summary of this ListPreference. If the summary has a[String formatting](https://developer.android.com/reference/java/lang/String#format(java.lang.String, java.lang.Object...))marker in it (i.e. "%s" or "%1$s"), then the current entry value will be substituted in its place.

<br />

|                                 Returns                                 ||
|----------------|---------------------------------------------------------|
| `CharSequence` | the summary with appropriate string substitution <br /> |

### getValue

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
String getValue ()
```

Returns the value of the key. This should be one of the entries in[getEntryValues()](https://developer.android.com/reference/android/support/v7/preference/ListPreference#getEntryValues()).

<br />

|                Returns                 ||
|----------|------------------------------|
| `String` | The value of the key. <br /> |

### setEntries

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setEntries (CharSequence[] entries)
```

Sets the human-readable entries to be shown in the list. This will be shown in subsequent dialogs.

Each entry must have a corresponding index in[setEntryValues(CharSequence[])](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntryValues(java.lang.CharSequence[])).

<br />

|                   Parameters                   ||
|-----------|-------------------------------------|
| `entries` | `CharSequence`: The entries. <br /> |

**See also:**

- [setEntryValues(CharSequence[])](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntryValues(java.lang.CharSequence[]))  

### setEntries

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setEntries (int entriesResId)
```

<br />

<br />

|                           Parameters                           ||
|----------------|------------------------------------------------|
| `entriesResId` | `int`: The entries array as a resource. <br /> |

**See also:**

- [setEntries(CharSequence[])](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntries(java.lang.CharSequence[]))  

### setEntryValues

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setEntryValues (int entryValuesResId)
```

<br />

<br />

|                               Parameters                                ||
|--------------------|-----------------------------------------------------|
| `entryValuesResId` | `int`: The entry values array as a resource. <br /> |

**See also:**

- [setEntryValues(CharSequence[])](https://developer.android.com/reference/android/support/v7/preference/ListPreference#setEntryValues(java.lang.CharSequence[]))  

### setEntryValues

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setEntryValues (CharSequence[] entryValues)
```

The array to find the value to save for a preference when an entry from entries is selected. If a user clicks on the second item in entries, the second item in this array will be saved to the preference.

<br />

|                                            Parameters                                            ||
|---------------|-----------------------------------------------------------------------------------|
| `entryValues` | `CharSequence`: The array to be used as values to save for the preference. <br /> |

### setSummary

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setSummary (CharSequence summary)
```

Sets the summary for this Preference with a CharSequence. If the summary has a[String formatting](https://developer.android.com/reference/java/lang/String#format(java.lang.String, java.lang.Object...))marker in it (i.e. "%s" or "%1$s"), then the current entry value will be substituted in its place when it's retrieved.

<br />

|                            Parameters                             ||
|-----------|--------------------------------------------------------|
| `summary` | `CharSequence`: The summary for the preference. <br /> |

### setValue

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setValue (String value)
```

Sets the value of the key. This should be one of the entries in[getEntryValues()](https://developer.android.com/reference/android/support/v7/preference/ListPreference#getEntryValues()).

<br />

|                       Parameters                        ||
|---------|------------------------------------------------|
| `value` | `String`: The value to set for the key. <br /> |

### setValueIndex

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setValueIndex (int index)
```

Sets the value to the given index from the entry values.

<br />

|                      Parameters                       ||
|---------|----------------------------------------------|
| `index` | `int`: The index of the value to set. <br /> |

## Protected methods

### onGetDefaultValue

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Object onGetDefaultValue (TypedArray a, 
                int index)
```

Called when a Preference is being inflated and the default value attribute needs to be read. Since different Preference types have different value types, the subclass should get and return the default value which will be its value type.

For example, if the value type is String, the body of the method would proxy to[getString(int)](https://developer.android.com/reference/android/content/res/TypedArray.html#getString(int)).

<br />

|                            Parameters                            ||
|---------|---------------------------------------------------------|
| `a`     | `TypedArray`: The set of attributes. <br />             |
| `index` | `int`: The index of the default value attribute. <br /> |

|                           Returns                           ||
|----------|---------------------------------------------------|
| `Object` | The default value of this preference type. <br /> |

### onRestoreInstanceState

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onRestoreInstanceState (Parcelable state)
```

Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState()). This function will never be called with a null state.

<br />

|                                                                                                       Parameters                                                                                                       ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `state` | `Parcelable`: The saved state that had previously been returned by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/ListPreference#onSaveInstanceState()). <br /> |

### onSaveInstanceState

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Parcelable onSaveInstanceState ()
```

Hook allowing a Preference to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can be reconstructed later.

<br />

|                                                                                                                             Returns                                                                                                                             ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) | A Parcelable object containing the current dynamic state of this Preference, or null if there is nothing interesting to save. The default implementation returns null. <br /> |

### onSetInitialValue

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSetInitialValue (boolean restoreValue, 
                Object defaultValue)
```

Implement this to set the initial value of the Preference.

If<var translate="no">restorePersistedValue</var>is true, you should restore the Preference value from the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html). If<var translate="no">restorePersistedValue</var>is false, you should set the Preference value to defaultValue that is given (and possibly store to SharedPreferences if[shouldPersist()](https://developer.android.com/reference/android/support/v7/preference/Preference#shouldPersist())is true).

In case of using[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore), the<var translate="no">restorePersistedValue</var>is always`true`but the default value (if provided) is set.

This may not always be called. One example is if it should not persist but there is no default value given.

<br />

|                                                                    Parameters                                                                    ||
|----------------|----------------------------------------------------------------------------------------------------------------------------------|
| `restoreValue` | `boolean`: True to restore the persisted value; false to use the given<var translate="no">defaultValue</var>. <br />             |
| `defaultValue` | `Object`: The default value for this Preference. Only use this if<var translate="no">restorePersistedValue</var>is false. <br /> |

-

  ## Interfaces

  - [DialogPreference.TargetFragment](https://developer.android.com/reference/android/support/v7/preference/DialogPreference.TargetFragment)
  - [Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceChangeListener)
  - [Preference.OnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)
  - [PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback)
  - [PreferenceFragmentCompat.OnPreferenceStartFragmentCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceStartFragmentCallback)
  - [PreferenceFragmentCompat.OnPreferenceStartScreenCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceStartScreenCallback)
  - [PreferenceGroup.PreferencePositionCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup.PreferencePositionCallback)
  - [PreferenceManager.OnDisplayPreferenceDialogListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnDisplayPreferenceDialogListener)
  - [PreferenceManager.OnNavigateToScreenListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnNavigateToScreenListener)
  - [PreferenceManager.OnPreferenceTreeClickListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnPreferenceTreeClickListener)
-

  ## Classes

  - [CheckBoxPreference](https://developer.android.com/reference/android/support/v7/preference/CheckBoxPreference)
  - [DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference)
  - [DropDownPreference](https://developer.android.com/reference/android/support/v7/preference/DropDownPreference)
  - [EditTextPreference](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference)
  - [EditTextPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/EditTextPreferenceDialogFragmentCompat)
  - [ListPreference](https://developer.android.com/reference/android/support/v7/preference/ListPreference)
  - [ListPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/ListPreferenceDialogFragmentCompat)
  - [MultiSelectListPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/MultiSelectListPreferenceDialogFragmentCompat)
  - [Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)
  - [Preference.BaseSavedState](https://developer.android.com/reference/android/support/v7/preference/Preference.BaseSavedState)
  - [PreferenceCategory](https://developer.android.com/reference/android/support/v7/preference/PreferenceCategory)
  - [PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)
  - [PreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceDialogFragmentCompat)
  - [PreferenceFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat)
  - [PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)
  - [PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)
  - [PreferenceManager.PreferenceComparisonCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.PreferenceComparisonCallback)
  - [PreferenceManager.SimplePreferenceComparisonCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.SimplePreferenceComparisonCallback)
  - [PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)
  - [PreferenceViewHolder](https://developer.android.com/reference/android/support/v7/preference/PreferenceViewHolder)
  - [R](https://developer.android.com/reference/android/support/v7/preference/R)
  - [R.anim](https://developer.android.com/reference/android/support/v7/preference/R.anim)
  - [R.attr](https://developer.android.com/reference/android/support/v7/preference/R.attr)
  - [R.bool](https://developer.android.com/reference/android/support/v7/preference/R.bool)
  - [R.color](https://developer.android.com/reference/android/support/v7/preference/R.color)
  - [R.dimen](https://developer.android.com/reference/android/support/v7/preference/R.dimen)
  - [R.drawable](https://developer.android.com/reference/android/support/v7/preference/R.drawable)
  - [R.id](https://developer.android.com/reference/android/support/v7/preference/R.id)
  - [R.integer](https://developer.android.com/reference/android/support/v7/preference/R.integer)
  - [R.layout](https://developer.android.com/reference/android/support/v7/preference/R.layout)
  - [R.string](https://developer.android.com/reference/android/support/v7/preference/R.string)
  - [R.style](https://developer.android.com/reference/android/support/v7/preference/R.style)
  - [R.styleable](https://developer.android.com/reference/android/support/v7/preference/R.styleable)
  - [SeekBarPreference](https://developer.android.com/reference/android/support/v7/preference/SeekBarPreference)
  - [SwitchPreferenceCompat](https://developer.android.com/reference/android/support/v7/preference/SwitchPreferenceCompat)
  - [TwoStatePreference](https://developer.android.com/reference/android/support/v7/preference/TwoStatePreference)