Added in API level 11
Deprecated in API level 29

MultiSelectListPreference


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

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

This preference will store a set of strings into the SharedPreferences. This set will contain one or more values 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

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

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

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 Array<CharSequence!>!

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

open MutableSet<String!>!

Retrieves the current value of the key.

open Unit
setEntries(entriesResId: Int)

open Unit

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

open Unit
setEntryValues(entryValuesResId: Int)

open Unit

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

open Unit

Sets the value of the key.

Protected methods
open Unit
onDialogClosed(positiveResult: Boolean)

open Any!

open Unit

open Parcelable!

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 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

MultiSelectListPreference

Added in API level 11
MultiSelectListPreference(context: Context!)

MultiSelectListPreference

Added in API level 11
MultiSelectListPreference(
    context: Context!,
    attrs: AttributeSet!)

MultiSelectListPreference

Added in API level 21
MultiSelectListPreference(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

MultiSelectListPreference

Added in API level 21
MultiSelectListPreference(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

findIndexOfValue

Added in API level 11
open fun findIndexOfValue(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

Added in API level 11
open fun getEntries(): 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.

getEntryValues

Added in API level 11
open fun getEntryValues(): Array<CharSequence!>!

Deprecated: Deprecated in Java.

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

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

getValues

Added in API level 11
open fun getValues(): MutableSet<String!>!

Deprecated: Deprecated in Java.

Retrieves the current value of the key.

setEntries

Added in API level 11
open fun setEntries(entriesResId: Int): Unit

Deprecated: Deprecated in Java.

Parameters
entriesResId Int: The entries array as a resource.

setEntries

Added in API level 11
open fun setEntries(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.

setEntryValues

Added in API level 11
open fun setEntryValues(entryValuesResId: Int): Unit

Deprecated: Deprecated in Java.

Parameters
entryValuesResId Int: The entry values array as a resource.

setEntryValues

Added in API level 11
open fun setEntryValues(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.

setValues

Added in API level 11
open fun setValues(values: MutableSet<String!>!): Unit

Deprecated: Deprecated in Java.

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

Parameters
values MutableSet<String!>!: The values to set for the key.

Protected methods

onDialogClosed

Added in API level 11
protected open fun onDialogClosed(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

Added in API level 11
protected open fun onGetDefaultValue(
    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

Added in API level 11
protected open fun onPrepareDialogBuilder(builder: AlertDialog.Builder!): Unit

Deprecated: Deprecated in Java.

onSaveInstanceState

Added in API level 11
protected open fun onSaveInstanceState(): 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

Added in API level 11
protected open fun onSetInitialValue(
    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.