ListPreference
open classListPreference: 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(java.lang.CharSequence[]) array.
Summary
| XML attributes | |
|---|---|
android:entries |
The human-readable array to present as a list. |
android:entryValues |
The array to find the value to save for a preference when an entry from entries is selected. |
| Inherited XML attributes | |
|---|---|
| Inherited constants | |
|---|---|
| Public constructors | |
|---|---|
ListPreference(context: Context!) |
|
ListPreference(context: Context!, attrs: AttributeSet!) |
|
ListPreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int) |
|
ListPreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int) |
|
| Public methods | |
|---|---|
| open Int |
findIndexOfValue(value: String!)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! |
getEntry()Returns the entry corresponding to the current value. |
| open Array<CharSequence!>! |
Returns the array of values to be saved for the preference. |
| open CharSequence! |
Returns the summary of this ListPreference. |
| open String! |
getValue()Returns the value of the key. |
| open Unit |
setEntries(entriesResId: Int) |
| open Unit |
setEntries(entries: Array<CharSequence!>!)Sets the human-readable entries to be shown in the list. |
| open Unit |
setEntryValues(entryValuesResId: Int) |
| open Unit |
setEntryValues(entryValues: Array<CharSequence!>!)The array to find the value to save for a preference when an entry from entries is selected. |
| open Unit |
setSummary(summary: CharSequence!)Sets the summary for this Preference with a CharSequence. |
| open Unit |
Sets the value of the key. |
| open Unit |
setValueIndex(index: Int)Sets the value to the given index from the entry values. |
| Protected methods | |
|---|---|
| open Unit |
onDialogClosed(positiveResult: Boolean) |
| open Any! |
onGetDefaultValue(a: TypedArray!, index: Int) |
| open Unit |
onPrepareDialogBuilder(builder: AlertDialog.Builder!) |
| open Unit |
onRestoreInstanceState(state: Parcelable!) |
| open Parcelable! | |
| open Unit |
onSetInitialValue(restoreValue: Boolean, defaultValue: Any!) |
| Inherited functions | |
|---|---|
XML attributes
android:entries
android:entriesMay 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:entryValuesMay be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".
Public constructors
ListPreference
ListPreference(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int)
ListPreference
ListPreference(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int,
defStyleRes: Int)
Public methods
findIndexOfValue
open funfindIndexOfValue(value: String!): Int
Deprecated: Deprecated in Java.
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 fungetEntries(): Array<CharSequence!>!
Deprecated: Deprecated in Java.
The list of entries to be shown in the list in subsequent dialogs.
| Return | |
|---|---|
Array<CharSequence!>! |
The list as an array. |
getEntry
open fungetEntry(): CharSequence!
Deprecated: Deprecated in Java.
Returns the entry corresponding to the current value.
| Return | |
|---|---|
CharSequence! |
The entry corresponding to the current value, or null. |
getEntryValues
open fungetEntryValues(): Array<CharSequence!>!
Deprecated: Deprecated in Java.
Returns the array of values to be saved for the preference.
| Return | |
|---|---|
Array<CharSequence!>! |
The array of values. |
getSummary
open fungetSummary(): CharSequence!
Deprecated: Deprecated in Java.
Returns the summary of this ListPreference. If the summary has a java.lang.String#format 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 |
getValue
open fungetValue(): String!
Deprecated: Deprecated in Java.
Returns the value of the key. This should be one of the entries in getEntryValues().
| Return | |
|---|---|
String! |
The value of the key. |
setEntries
open funsetEntries(entriesResId: Int): Unit
Deprecated: Deprecated in Java.
| Parameters | |
|---|---|
entriesResId |
Int: The entries array as a resource. |
See Also
setEntries
open funsetEntries(entries: Array<CharSequence!>!): Unit
Deprecated: Deprecated in Java.
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(java.lang.CharSequence[]).
| Parameters | |
|---|---|
entries |
Array<CharSequence!>!: The entries. |
See Also
setEntryValues
open funsetEntryValues(entryValuesResId: Int): Unit
Deprecated: Deprecated in Java.
| Parameters | |
|---|---|
entryValuesResId |
Int: The entry values array as a resource. |
See Also
setEntryValues
open funsetEntryValues(entryValues: Array<CharSequence!>!): Unit
Deprecated: Deprecated in Java.
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. |
setSummary
open funsetSummary(summary: CharSequence!): Unit
Deprecated: Deprecated in Java.
Sets the summary for this Preference with a CharSequence. If the summary has a java.lang.String#format 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. |
setValue
open funsetValue(value: String!): Unit
Deprecated: Deprecated in Java.
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 funsetValueIndex(index: Int): Unit
Deprecated: Deprecated in Java.
Sets the value to the given index from the entry values.
| Parameters | |
|---|---|
index |
Int: The index of the value to set. |
Protected methods
onDialogClosed
protected open funonDialogClosed(positiveResult: Boolean): Unit
Deprecated: Deprecated in Java.
| Parameters | |
|---|---|
positiveResult |
Boolean: Whether the positive button was clicked (true), or the negative button was clicked or the dialog was canceled (false). |
onGetDefaultValue
protected open funonGetDefaultValue(
a: TypedArray!,
index: Int
): Any!
Deprecated: Deprecated in Java.
| Parameters | |
|---|---|
a |
TypedArray!: The set of attributes. |
index |
Int: The index of the default value attribute. |
| Return | |
|---|---|
Any! |
The default value of this preference type. |
onPrepareDialogBuilder
protected open funonPrepareDialogBuilder(builder: AlertDialog.Builder!): Unit
Deprecated: Deprecated in Java.
onRestoreInstanceState
protected open funonRestoreInstanceState(state: Parcelable!): Unit
Deprecated: Deprecated in Java.
| Parameters | |
|---|---|
state |
Parcelable!: The saved state that had previously been returned by onSaveInstanceState. |
onSaveInstanceState
protected open funonSaveInstanceState(): Parcelable!
Deprecated: Deprecated in Java.
| Return | |
|---|---|
Parcelable! |
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. |
onSetInitialValue
protected open funonSetInitialValue(
restoreValue: Boolean,
defaultValue: Any!
): Unit
Deprecated: Deprecated in Java.
| Parameters | |
|---|---|
restorePersistedValue |
True to restore the persisted value; false to use the given defaultValue. |
defaultValue |
Any!: The default value for this Preference. Only use this if restorePersistedValue is false. |