ListPreference

public class ListPreference
extends DialogPreference

java.lang.Object
   ↳ 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

class ListPreference.SimpleSummaryProvider

A simple Preference.SummaryProvider implementation for a ListPreference

Inherited constants

Public constructors

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

Public methods

int findIndexOfValue(String value)

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

CharSequence[] getEntries()

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

CharSequence getEntry()

Returns the entry corresponding to the current value.

CharSequence[] getEntryValues()

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

CharSequence getSummary()

Returns the summary of this preference.

String getValue()

Returns the value of the key.

void setEntries(CharSequence[] entries)

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

void setEntries(int entriesResId)
void setEntryValues(int entryValuesResId)
void setEntryValues(CharSequence[] entryValues)

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

void setSummary(CharSequence summary)

Sets the summary for this preference with a CharSequence.

void setValue(String value)

Sets the value of the key.

void setValueIndex(int index)

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

Protected methods

Object onGetDefaultValue(TypedArray a, int index)

Called when a preference is being inflated and the default value attribute needs to be read.

void onRestoreInstanceState(Parcelable state)

Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState().

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.

void onSetInitialValue(Object defaultValue)

Implement this to set the initial value of the preference.

Inherited methods