# ListPreference

Artifact: [androidx.preference:preference](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/ListPreference.java+class:androidx.preference.ListPreference) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

*** ** * ** ***


```
class ListPreference : DialogPreference
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [androidx.preference.Preference](https://developer.android.com/reference/kotlin/androidx/preference/Preference) |||
|   | ↳ | [androidx.preference.DialogPreference](https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference) ||
|   |   | ↳ | [androidx.preference.ListPreference](https://developer.android.com/reference/kotlin/androidx/preference/ListPreference) |

Known direct subclasses [DropDownPreference](https://developer.android.com/reference/kotlin/androidx/preference/DropDownPreference)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/DropDownPreference` | A `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference` that presents the options in a drop down menu rather than a dialog. |

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/preference/Preference` that displays a list of entries as a dialog.

This preference saves a string value. This string will be the value from the `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntryValues(java.lang.CharSequence[])` array.

name android:entries

name android:entryValues

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/preference/ListPreference.SimpleSummaryProvider : https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider<https://developer.android.com/reference/kotlin/androidx/preference/ListPreference!>` A simple `https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider` implementation for a `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#ListPreference(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` |
| `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#ListPreference(android.content.Context,android.util.AttributeSet)(context: https://developer.android.com/reference/android/content/Context.html, attrs: https://developer.android.com/reference/android/util/AttributeSet.html?)` |
| `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#ListPreference(android.content.Context,android.util.AttributeSet,int)(context: https://developer.android.com/reference/android/content/Context.html, attrs: https://developer.android.com/reference/android/util/AttributeSet.html?, defStyleAttr: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#ListPreference(android.content.Context,android.util.AttributeSet,int,int)( context: https://developer.android.com/reference/android/content/Context.html, attrs: https://developer.android.com/reference/android/util/AttributeSet.html?, defStyleAttr: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, defStyleRes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#findIndexOfValue(java.lang.String)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the index of the given value (in the entry values array). |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#getEntries()()` The list of entries to be shown in the list in subsequent dialogs. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#getEntry()()` Returns the entry corresponding to the current value. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#getEntryValues()()` Returns the array of values to be saved for the preference. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#getSummary()()` Returns the summary of this preference. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#getValue()()` Returns the value of the key. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntries(java.lang.CharSequence[])(entries: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!)` Sets the human-readable entries to be shown in the list. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntries(int)(entriesResId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntryValues(java.lang.CharSequence[])(entryValues: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!)` The array to find the value to save for a preference when an entry from entries is selected. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntryValues(int)(entryValuesResId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setSummary(java.lang.CharSequence)(summary: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)` Sets the summary for this preference with a CharSequence. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setValue(java.lang.String)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Sets the value of the key. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setValueIndex(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the value to the given index from the entry values. |

| ### Protected functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#onGetDefaultValue(android.content.res.TypedArray,int)(a: https://developer.android.com/reference/android/content/res/TypedArray.html, index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Called when a preference is being inflated and the default value attribute needs to be read. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#onRestoreInstanceState(android.os.Parcelable)(state: https://developer.android.com/reference/android/os/Parcelable.html?)` Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onSaveInstanceState()`. |
| `https://developer.android.com/reference/android/os/Parcelable.html?` | `https://developer.android.com/reference/kotlin/androidx/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. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#onSetInitialValue(java.lang.Object)(defaultValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` Implement this to set the initial value of the preference. |

### Inherited Constants

From [androidx.preference.Preference](https://developer.android.com/reference/kotlin/androidx/preference/Preference) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#DEFAULT_ORDER() = 2147483647`

Specify for `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setOrder(int)` if a specific order is not required.

### Inherited functions

From [java.lang.Comparable](https://developer.android.com/reference/java/lang/Comparable.html) `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-comparable/compare-to.html(p: T!)` From [androidx.preference.DialogPreference](https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference) `https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#getDialogIcon()()`

Returns the icon to be shown on subsequent dialogs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#getDialogLayoutResource()()`

Returns the layout resource that is used as the content view for subsequent dialogs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#getDialogMessage()()`

Returns the message to be shown on subsequent dialogs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#getDialogTitle()()`

Returns the title to be shown on subsequent dialogs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#getNegativeButtonText()()`

Returns the text of the negative button to be shown on subsequent dialogs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#getPositiveButtonText()()`

Returns the text of the positive button to be shown on subsequent dialogs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#onClick()()`

Processes a click on the preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setDialogIcon(android.graphics.drawable.Drawable)(dialogIcon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?)`

Sets the icon of the dialog.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setDialogIcon(int)(dialogIconRes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the icon (resource ID) of the dialog.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setDialogLayoutResource(int)(dialogLayoutResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the layout resource that is inflated as the `https://developer.android.com/reference/android/view/View.html` to be shown as the content view of subsequent dialogs.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setDialogMessage(java.lang.CharSequence)(dialogMessage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)`

Sets the message of the dialog.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setDialogMessage(int)(dialogMessageResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setDialogTitle(java.lang.CharSequence)(dialogTitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)`

Sets the title of the dialog.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setDialogTitle(int)(dialogTitleResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setNegativeButtonText(java.lang.CharSequence)(negativeButtonText: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)`

Sets the text of the negative button of the dialog.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setNegativeButtonText(int)(negativeButtonTextResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setPositiveButtonText(java.lang.CharSequence)(positiveButtonText: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)`

Sets the text of the positive button of the dialog.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/DialogPreference#setPositiveButtonText(int)(positiveButtonTextResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` From [androidx.preference.Preference](https://developer.android.com/reference/kotlin/androidx/preference/Preference) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#callChangeListener(java.lang.Object)(newValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

Call this method after the user changes the preference, but before the internal state is set.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#compareTo(androidx.preference.Preference)(another: https://developer.android.com/reference/kotlin/androidx/preference/Preference)`

Compares preference objects based on order (if set), otherwise alphabetically on the titles.
`T?` `<T : https://developer.android.com/reference/kotlin/androidx/preference/Preference?> https://developer.android.com/reference/kotlin/androidx/preference/Preference#findPreferenceInHierarchy(java.lang.String)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`

Finds a preference in the entire hierarchy (above or below this preference) with the given key.
`https://developer.android.com/reference/android/content/Context.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getContext()()`

Returns the `https://developer.android.com/reference/android/content/Context.html` of this preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getDependency()()`

Returns the key of the dependency on this preference.
`https://developer.android.com/reference/android/os/Bundle.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getExtras()()`

Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getFragment()()`

Return the fragment class name associated with this preference.
`https://developer.android.com/reference/android/graphics/drawable/Drawable.html?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getIcon()()`

Returns the icon of this preference.
`https://developer.android.com/reference/android/content/Intent.html?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getIntent()()`

Return the `https://developer.android.com/reference/android/content/Intent.html` associated with this preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getKey()()`

Gets the key for this preference, which is also the key used for storing values into `https://developer.android.com/reference/android/content/SharedPreferences.html` or `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceDataStore`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getLayoutResource()()`

Gets the layout resource that will be shown as the `https://developer.android.com/reference/android/view/View.html` for this preference.
`https://developer.android.com/reference/kotlin/androidx/preference/Preference.OnPreferenceChangeListener?` `https://developer.android.com/reference/kotlin/androidx/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).
`https://developer.android.com/reference/kotlin/androidx/preference/Preference.OnPreferenceClickListener?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getOnPreferenceClickListener()()`

Returns the callback to be invoked when this preference is clicked.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getOrder()()`

Gets the order of this preference with respect to other preference objects on the same level.
`https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getParent()()`

Returns the `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceGroup` which is this preference assigned to or `null` if this preference is not assigned to any group or is a root preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getPersistedBoolean(boolean)(defaultReturnValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Attempts to get a persisted `https://developer.android.com/reference/java/lang/Boolean.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getPersistedFloat(float)(defaultReturnValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Attempts to get a persisted `https://developer.android.com/reference/java/lang/Float.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getPersistedInt(int)(defaultReturnValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Attempts to get a persisted `https://developer.android.com/reference/java/lang/Integer.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getPersistedLong(long)(defaultReturnValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

Attempts to get a persisted `https://developer.android.com/reference/java/lang/Long.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getPersistedString(java.lang.String)(defaultReturnValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)`

Attempts to get a persisted set of Strings if this preference is persistent.
`(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getPersistedStringSet(java.util.Set<java.lang.String>)(defaultReturnValue: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!)`

Attempts to get a persisted set of Strings if this preference is persistent.
`https://developer.android.com/reference/kotlin/androidx/preference/PreferenceDataStore?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getPreferenceDataStore()()`

Returns `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceDataStore` used by this preference.
`https://developer.android.com/reference/kotlin/androidx/preference/PreferenceManager!` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getPreferenceManager()()`

Gets the `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceManager` that manages this preference object's tree.
`https://developer.android.com/reference/android/content/SharedPreferences.html?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getSharedPreferences()()`

Returns the `https://developer.android.com/reference/android/content/SharedPreferences.html` where this preference can read its value(s).
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getShouldDisableView()()`

Checks whether this preference should disable its view when it's action is disabled.
`https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getSummaryProvider()()`

Returns the `https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider` used to configure the summary of this preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getTitle()()`

Returns the title of this preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#getWidgetLayoutResource()()`

Gets the layout resource for the controllable widget portion of this preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#hasKey()()`

Checks whether this preference has a valid key.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#isCopyingEnabled()()`

Returns whether the summary of this preference can be copied to the clipboard by long pressing on the preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#isEnabled()()`

Checks whether this preference should be enabled in the list.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#isIconSpaceReserved()()`

Returns whether the space of this preference icon view is reserved.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#isPersistent()()`

Checks whether this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#isSelectable()()`

Checks whether this preference should be selectable in the list.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#isShown()()`

Checks whether this preference is shown to the user in the hierarchy.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#isSingleLineTitle()()`

Gets whether the title of this preference is constrained to a single line.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#isVisible()()`

Checks whether this preference should be visible to the user.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#notifyChanged()()`

Should be called when the data of this `https://developer.android.com/reference/kotlin/androidx/preference/Preference` has changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#notifyDependencyChange(boolean)(disableDependents: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Notifies any listening dependents of a change that affects the dependency.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#notifyHierarchyChanged()()`

Should be called when a preference has been added/removed from this group, or the ordering should be re-evaluated.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onAttached()()`

Called when the preference hierarchy has been attached to the list of preferences.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onAttachedToHierarchy(androidx.preference.PreferenceManager)(preferenceManager: https://developer.android.com/reference/kotlin/androidx/preference/PreferenceManager)`

Called when this preference has been attached to a preference hierarchy.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onBindViewHolder(androidx.preference.PreferenceViewHolder)(holder: https://developer.android.com/reference/kotlin/androidx/preference/PreferenceViewHolder)`

Binds the created View to the data for this preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onDependencyChanged(androidx.preference.Preference,boolean)(dependency: https://developer.android.com/reference/kotlin/androidx/preference/Preference, disableDependent: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Called when the dependency changes.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onDetached()()`

Called when the preference hierarchy has been detached from the list of preferences.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper
[onInitializeAccessibilityNodeInfo](https://developer.android.com/reference/kotlin/androidx/preference/Preference#onInitializeAccessibilityNodeInfo(androidx.core.view.accessibility.AccessibilityNodeInfoCompat))(info: https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat!)`

**This function is deprecated.**

Preferences aren't views.

<br />

`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onParentChanged(androidx.preference.Preference,boolean)(parent: https://developer.android.com/reference/kotlin/androidx/preference/Preference, disableChild: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Called when the implicit parent dependency changes.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onPrepareForRemoval()()`

Called when this preference is being removed from the hierarchy.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[onSetInitialValue](https://developer.android.com/reference/kotlin/androidx/preference/Preference#onSetInitialValue(boolean,java.lang.Object))(restorePersistedValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, defaultValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

**This function is deprecated.**

Use `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onSetInitialValue(java.lang.Object)` instead.

<br />

`https://developer.android.com/reference/android/os/Bundle.html?` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#peekExtras()()`

Return the extras Bundle object associated with this preference, returning `null` if there is not currently one.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#persistBoolean(boolean)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Attempts to persist a `https://developer.android.com/reference/java/lang/Boolean.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#persistFloat(float)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Attempts to persist a `https://developer.android.com/reference/java/lang/Float.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#persistInt(int)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Attempts to persist an `https://developer.android.com/reference/java/lang/Integer.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#persistLong(long)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

Attempts to persist a `https://developer.android.com/reference/java/lang/Long.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#persistString(java.lang.String)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)`

Attempts to persist a `https://developer.android.com/reference/java/lang/String.html` if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#persistStringSet(java.util.Set<java.lang.String>)(values: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!)`

Attempts to persist a set of Strings if this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)(container: https://developer.android.com/reference/android/os/Bundle.html)`

Restore this preference hierarchy's previously saved state from the given container.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)(container: https://developer.android.com/reference/android/os/Bundle.html)`

Store this preference hierarchy's frozen state into the given container.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setCopyingEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether the summary of this preference can be copied to the clipboard by long pressing on the preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setDefaultValue(java.lang.Object)(defaultValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)`

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.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setDependency(java.lang.String)(dependencyKey: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)`

Sets the key of a preference that this preference will depend on.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether this preference is enabled.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setFragment(java.lang.String)(fragment: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)`

Sets the class name of a fragment to be shown when this preference is clicked.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setIcon(android.graphics.drawable.Drawable)(icon: https://developer.android.com/reference/android/graphics/drawable/Drawable.html?)`

Sets the icon for this preference with a Drawable.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setIcon(int)(iconResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the icon for this preference with a resource ID.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setIconSpaceReserved(boolean)(iconSpaceReserved: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether to reserve the space of this preference icon view when no icon is provided.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setIntent(android.content.Intent)(intent: https://developer.android.com/reference/android/content/Intent.html?)`

Sets an `https://developer.android.com/reference/android/content/Intent.html` to be used for `https://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent)` when this preference is clicked.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setKey(java.lang.String)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)`

Sets the key for this preference, which is used as a key to the `https://developer.android.com/reference/android/content/SharedPreferences.html` or `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceDataStore`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setLayoutResource(int)(layoutResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the layout resource that is inflated as the `https://developer.android.com/reference/android/view/View.html` to be shown for this preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setOnPreferenceChangeListener(androidx.preference.Preference.OnPreferenceChangeListener)(
onPreferenceChangeListener: https://developer.android.com/reference/kotlin/androidx/preference/Preference.OnPreferenceChangeListener?
)`

Sets the callback to be invoked when this preference is changed by the user (but before the internal state has been updated).
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setOnPreferenceClickListener(androidx.preference.Preference.OnPreferenceClickListener)(
onPreferenceClickListener: https://developer.android.com/reference/kotlin/androidx/preference/Preference.OnPreferenceClickListener?
)`

Sets the callback to be invoked when this preference is clicked.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setOrder(int)(order: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the order of this preference with respect to other preference objects on the same level.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setPersistent(boolean)(persistent: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether this preference is persistent.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setPreferenceDataStore(androidx.preference.PreferenceDataStore)(dataStore: https://developer.android.com/reference/kotlin/androidx/preference/PreferenceDataStore?)`

Sets a `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceDataStore` to be used by this preference instead of using `https://developer.android.com/reference/android/content/SharedPreferences.html`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setSelectable(boolean)(selectable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether this preference is selectable.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setShouldDisableView(boolean)(shouldDisableView: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether this preference should disable its view when it gets disabled.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setSingleLineTitle(boolean)(singleLineTitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether to constrain the title of this preference to a single line instead of letting it wrap onto multiple lines.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setSummary(int)(summaryResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the summary for this preference with a resource ID.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setSummaryProvider(androidx.preference.Preference.SummaryProvider)(summaryProvider: https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider?)`

Set a `https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider` that will be invoked whenever the summary of this preference is requested.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)`

Sets the title for this preference with a CharSequence.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setTitle(int)(titleResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the title for this preference with a resource ID.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setViewId(int)(viewId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Set the ID that will be assigned to the overall View representing this preference, once bound.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setVisible(boolean)(visible: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether this preference should be visible to the user.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setWidgetLayoutResource(int)(widgetLayoutResId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Sets the layout for the controllable widget portion of this preference.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#shouldDisableDependents()()`

Checks whether this preference's dependents should currently be disabled.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#shouldPersist()()`

Checks whether, at the given time this method is called, this preference should store/restore its value(s) into the `https://developer.android.com/reference/android/content/SharedPreferences.html` or into `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceDataStore` if assigned.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` `https://developer.android.com/reference/kotlin/androidx/preference/Preference#toString()()`

## Public constructors

### ListPreference

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
ListPreference(context: Context)
```

### ListPreference

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

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

### ListPreference

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
ListPreference(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
```

### ListPreference

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
ListPreference(
    context: Context,
    attrs: AttributeSet?,
    defStyleAttr: Int,
    defStyleRes: Int
)
```

## Public functions

### findIndexOfValue

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun findIndexOfValue(value: String!): Int
```

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

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The value whose index should be returned |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the value, or -1 if not found |

### getEntries

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun getEntries(): Array<CharSequence!>!
```

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!` | The list as an array |

### getEntry

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun getEntry(): CharSequence?
```

Returns the entry corresponding to the current value.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | The entry corresponding to the current value, or `null` |

### getEntryValues

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun getEntryValues(): Array<CharSequence!>!
```

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!` | The array of values |

### getSummary

```
fun getSummary(): CharSequence?
```

Returns the summary of this preference. If a `https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider` has been set for this preference, it will be used to provide the summary returned by this method.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | The summary |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setSummary(java.lang.CharSequence)` |   |
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setSummaryProvider(androidx.preference.Preference.SummaryProvider)` |   |

### getValue

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun getValue(): String!
```

Returns the value of the key. This should be one of the entries in `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#getEntryValues()`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The value of the key |

### setEntries

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun setEntries(entries: Array<CharSequence!>!): Unit
```

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 `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntryValues(java.lang.CharSequence[])`.

| Parameters |
|---|---|
| `entries: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!` | The entries |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntryValues(java.lang.CharSequence[])` |   |

### setEntries

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun setEntries(entriesResId: @ArrayRes Int): Unit
```

| Parameters |
|---|---|
| `entriesResId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The entries array as a resource |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntries(java.lang.CharSequence[])` |   |

### setEntryValues

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun setEntryValues(entryValues: Array<CharSequence!>!): Unit
```

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.

| Parameters |
|---|---|
| `entryValues: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!>!` | The array to be used as values to save for the preference |

### setEntryValues

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun setEntryValues(entryValuesResId: @ArrayRes Int): Unit
```

| Parameters |
|---|---|
| `entryValuesResId: @https://developer.android.com/reference/kotlin/androidx/annotation/ArrayRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The entry values array as a resource |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#setEntryValues(java.lang.CharSequence[])` |   |

### setSummary

```
fun setSummary(summary: CharSequence?): Unit
```

Sets the summary for this preference with a CharSequence.

You can also use a `https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider` to dynamically configure the summary of this preference.

| Parameters |
|---|---|
| `summary: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | The summary for the preference |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If a `https://developer.android.com/reference/kotlin/androidx/preference/Preference.SummaryProvider` has already been set. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#setSummaryProvider(androidx.preference.Preference.SummaryProvider)` |   |

### setValue

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun setValue(value: String!): Unit
```

Sets the value of the key. This should be one of the entries in `https://developer.android.com/reference/kotlin/androidx/preference/ListPreference#getEntryValues()`.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The value to set for the key |

### setValueIndex

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/preference#1.0.0)

```
fun setValueIndex(index: Int): Unit
```

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

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the value to set |

## Protected functions

### onGetDefaultValue

```
protected fun onGetDefaultValue(a: TypedArray, index: Int): Any!
```

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 `https://developer.android.com/reference/android/content/res/TypedArray.html#getString(int)`.

| Parameters |
|---|---|
| `a: https://developer.android.com/reference/android/content/res/TypedArray.html` | The set of attributes |
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the default value attribute |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | The default value of this preference type |

### onRestoreInstanceState

```
protected fun onRestoreInstanceState(state: Parcelable?): Unit
```

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

| Parameters |
|---|---|
| `state: https://developer.android.com/reference/android/os/Parcelable.html?` | The saved state that had previously been returned by `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onSaveInstanceState()`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onSaveInstanceState()` |   |
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#restoreHierarchyState(android.os.Bundle)` |   |

### onSaveInstanceState

```
protected fun onSaveInstanceState(): Parcelable?
```

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.

| Returns |
|---|---|
| `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`. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#onRestoreInstanceState(android.os.Parcelable)` |   |
| `https://developer.android.com/reference/kotlin/androidx/preference/Preference#saveHierarchyState(android.os.Bundle)` |   |

### onSetInitialValue

```
protected fun onSetInitialValue(defaultValue: Any!): Unit
```

Implement this to set the initial value of the preference.

If you are persisting values to `https://developer.android.com/reference/android/content/SharedPreferences.html` or a `https://developer.android.com/reference/kotlin/androidx/preference/PreferenceDataStore` you should restore the saved value for the preference.

If you are not persisting values, or there is no value saved for the preference, you should set the value of the preference to <var translate="no">defaultValue</var>.

| Parameters |
|---|---|
| `defaultValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | The default value for the preference if set, otherwise `null`. |