ListPreference

open class ListPreference : DialogPreference
kotlin.Any
   ↳ androidx.preference.Preference
   ↳ androidx.preference.DialogPreference
   ↳ androidx.preference.ListPreference

A Preference that displays a list of entries as a dialog.

This preference saves a string value. This string will be the value from the setEntryValues(CharSequence[]) array.

Summary

Nested classes

A simple androidx.preference.Preference.SummaryProvider implementation for a ListPreference.

Inherited constants

Public constructors

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

<init>(context: Context!, attrs: AttributeSet!)

<init>(context: Context!)

Public methods

open Int

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

open Array<CharSequence!>!

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

open CharSequence!

Returns the entry corresponding to the current value.

open Array<CharSequence!>!

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

open CharSequence!

open String!

Returns the value of the key.

open Unit

Sets the human-readable entries to be shown in the list.

open Unit
setEntries(@ArrayRes entriesResId: Int)

open Unit

The array to find the value to save for a preference when an entry from entries is selected.

open Unit
setEntryValues(@ArrayRes entryValuesResId: Int)

open Unit

open Unit
setValue(value: String!)

Sets the value of the key.

open Unit

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

Protected methods

open Any!

open Unit

open Parcelable!

open Unit
onSetInitialValue(defaultValue: Any?)

Inherited functions

Public constructors

<init>

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

<init>

ListPreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

<init>

ListPreference(context: Context!, attrs: AttributeSet!)

<init>

ListPreference(context: Context!)

Public methods

findIndexOfValue

open fun findIndexOfValue(value: String!): Int

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

Parameters
value String!: The value whose index should be returned
Return
Int: The index of the value, or -1 if not found

getEntries

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

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

Return
Array<CharSequence!>!: The list as an array

getEntry

open fun getEntry(): CharSequence!

Returns the entry corresponding to the current value.

Return
CharSequence!: The entry corresponding to the current value, or null

getEntryValues

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

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

Return
Array<CharSequence!>!: The array of values

getSummary

open fun getSummary(): CharSequence!

getValue

open fun getValue(): String!

Returns the value of the key. This should be one of the entries in getEntryValues().

Return
String!: The value of the key

setEntries

open 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 setEntryValues(CharSequence[]).

Parameters
entries Array<CharSequence!>!: The entries

setEntries

open fun setEntries(@ArrayRes entriesResId: Int): Unit
Parameters
entriesResId Int: The entries array as a resource

setEntryValues

open 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 Array<CharSequence!>!: The array to be used as values to save for the preference

setEntryValues

open fun setEntryValues(@ArrayRes entryValuesResId: Int): Unit
Parameters
entryValuesResId Int: The entry values array as a resource

setSummary

open fun setSummary(summary: CharSequence!): Unit

setValue

open fun setValue(value: String!): Unit

Sets the value of the key. This should be one of the entries in getEntryValues().

Parameters
value String!: The value to set for the key

setValueIndex

open fun setValueIndex(index: Int): Unit

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

Parameters
index Int: The index of the value to set

Protected methods

onGetDefaultValue

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

onRestoreInstanceState

protected open fun onRestoreInstanceState(state: Parcelable!): Unit

onSaveInstanceState

protected open fun onSaveInstanceState(): Parcelable!

onSetInitialValue

protected open fun onSetInitialValue(defaultValue: Any?): Unit