ListPreference

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

A 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[]) array.

Summary

XML attributes
android:entries

android:entryValues

Inherited XML attributes
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 Unit

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

open Unit
setEntryValues(entryValuesResId: Int)

open Int

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

open Unit

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

open Unit
setEntries(entriesResId: Int)

open Array<CharSequence!>!

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

open String!

Returns the value of the key.

open CharSequence!

Returns the entry corresponding to the current value.

open Unit
setValue(value: String!)

Sets the value of the key.

open Unit

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

open Unit

Sets the summary for this Preference with a CharSequence.

open Array<CharSequence!>!

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

open CharSequence!

Returns the summary of this ListPreference.

Protected methods
open Unit

open Parcelable!

open Unit

open Any!

open Unit
onDialogClosed(positiveResult: Boolean)

open Unit
onSetInitialValue(restoreValue: Boolean, defaultValue: Any!)

Inherited functions

XML attributes

android:entries

android:entries
The human-readable array to present as a list. Each entry must have a corresponding index in entryValues.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:entryValues

android: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.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

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

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(entryValuesResId: Int): Unit
Parameters
entryValuesResId Int: The entry values array as a resource.

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.

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(entriesResId: Int): Unit
Parameters
entriesResId Int: The entries array as a resource.

getEntryValues

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

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

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

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.

getEntry

open fun getEntry(): CharSequence!

Returns the entry corresponding to the current value.

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

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.

setSummary

open fun setSummary(summary: CharSequence!): Unit

Sets the summary for this Preference with a CharSequence. If the summary has a String formatting marker in it (i.e. "%s" or "%1$s"), then the current entry value will be substituted in its place when it's retrieved.

Parameters
summary CharSequence!: The summary for the preference.

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.

getSummary

open fun getSummary(): CharSequence!

Returns the summary of this ListPreference. If the summary has a String formatting marker in it (i.e. "%s" or "%1$s"), then the current entry value will be substituted in its place.

Return
CharSequence!: the summary with appropriate string substitution

Protected methods

onPrepareDialogBuilder

protected open fun onPrepareDialogBuilder(builder: AlertDialog.Builder!): Unit

onSaveInstanceState

protected open fun onSaveInstanceState(): Parcelable!

onRestoreInstanceState

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

onGetDefaultValue

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

onDialogClosed

protected open fun onDialogClosed(positiveResult: Boolean): Unit

onSetInitialValue

protected open fun onSetInitialValue(restoreValue: Boolean, defaultValue: Any!): Unit