Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

MultiSelectListPreference

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

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

This preference saves a set of strings. This set will contain one or more mValues from the setEntryValues(CharSequence[]) array.

Summary

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 mValues array).

open Array<CharSequence!>!

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

open Array<CharSequence!>!

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

open MutableSet<String!>!

Retrieves the current values 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

Sets the values for the key.

Protected methods

open BooleanArray!

open Any!

open Unit

open Parcelable!

open Unit
onSetInitialValue(defaultValue: Any?)

Inherited functions

Public constructors

<init>

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

<init>

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

<init>

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

<init>

MultiSelectListPreference(context: Context!)

Public methods

findIndexOfValue

open fun findIndexOfValue(value: String!): Int

Returns the index of the given value (in the entry mValues 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

getEntryValues

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

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

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

getValues

open fun getValues(): MutableSet<String!>!

Retrieves the current values of the key.

Return
MutableSet<String!>!: The set of current values

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 mValues to save for the preference

setEntryValues

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

setValues

open fun setValues(values: MutableSet<String!>!): Unit

Sets the values for the key. This should contain entries in getEntryValues().

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

Protected methods

getSelectedItems

protected open fun getSelectedItems(): BooleanArray!

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