MultiSelectListPreference
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 array.
name android:entries
name android:entryValues
Summary
Public constructors |
|---|
MultiSelectListPreference(context: Context) |
MultiSelectListPreference(context: Context, attrs: AttributeSet?) |
MultiSelectListPreference( |
MultiSelectListPreference( |
Public functions |
|
|---|---|
Int |
findIndexOfValue(value: String!)Returns the index of the given value (in the entry mValues array). |
Array<CharSequence!>! |
The list of entries to be shown in the list in subsequent dialogs. |
Array<CharSequence!>! |
Returns the array of mValues to be saved for the preference. |
(Mutable)Set<String!>! |
Retrieves the current values of the key. |
Unit |
setEntries(entries: Array<CharSequence!>!)Sets the human-readable entries to be shown in the list. |
Unit |
setEntries(entriesResId: @ArrayRes Int) |
Unit |
setEntryValues(entryValues: Array<CharSequence!>!)The array to find the value to save for a preference when an entry from entries is selected. |
Unit |
setEntryValues(entryValuesResId: @ArrayRes Int) |
Unit |
Sets the values for the key. |
Protected functions |
|
|---|---|
BooleanArray<Boolean>! |
|
Any? |
onGetDefaultValue(a: TypedArray, index: Int)Called when a preference is being inflated and the default value attribute needs to be read. |
Unit |
onRestoreInstanceState(state: Parcelable?)Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by |
Parcelable? |
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. |
Unit |
onSetInitialValue(defaultValue: Any!)Implement this to set the initial value of the preference. |
Inherited Constants |
||
|---|---|---|
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
MultiSelectListPreference
MultiSelectListPreference(context: Context, attrs: AttributeSet?)
MultiSelectListPreference
MultiSelectListPreference(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int
)
MultiSelectListPreference
MultiSelectListPreference(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
)
Public functions
findIndexOfValue
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 |
| Returns | |
|---|---|
Int |
The index of the value, or -1 if not found |
getEntries
fun getEntries(): Array<CharSequence!>!
The list of entries to be shown in the list in subsequent dialogs.
| Returns | |
|---|---|
Array<CharSequence!>! |
The list as an array |
getEntryValues
fun getEntryValues(): Array<CharSequence!>!
Returns the array of mValues to be saved for the preference.
| Returns | |
|---|---|
Array<CharSequence!>! |
The array of mValues |
getValues
fun getValues(): (Mutable)Set<String!>!
Retrieves the current values of the key.
setEntries
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.
| Parameters | |
|---|---|
entries: Array<CharSequence!>! |
The entries |
| See also | |
|---|---|
setEntryValues |
setEntryValues
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
fun setEntryValues(entryValuesResId: @ArrayRes Int): Unit
| See also | |
|---|---|
setEntryValues |
Protected functions
onGetDefaultValue
protected fun onGetDefaultValue(a: TypedArray, index: Int): Any?
Called when a preference is being inflated and the default value attribute needs to be read. Since different preference types have different value types, the subclass should get and return the default value which will be its value type.
For example, if the value type is String, the body of the method would proxy to getString.
| Parameters | |
|---|---|
a: TypedArray |
The set of attributes |
index: Int |
The index of the default value attribute |
| Returns | |
|---|---|
Any? |
The default value of this preference type |
onRestoreInstanceState
protected fun onRestoreInstanceState(state: Parcelable?): Unit
Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState. This function will never be called with a null state.
| Parameters | |
|---|---|
state: Parcelable? |
The saved state that had previously been returned by |
| See also | |
|---|---|
onSaveInstanceState |
|
restoreHierarchyState |
onSaveInstanceState
protected fun onSaveInstanceState(): Parcelable?
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. This state should only contain information that is not persistent or can be reconstructed later.
| Returns | |
|---|---|
Parcelable? |
A Parcelable object containing the current dynamic state of this preference, or |
| See also | |
|---|---|
onRestoreInstanceState |
|
saveHierarchyState |
onSetInitialValue
protected fun onSetInitialValue(defaultValue: Any!): Unit
Implement this to set the initial value of the preference.
If you are persisting values to SharedPreferences or a PreferenceDataStore you should restore the saved value for the preference.
If you are not persisting values, or there is no value saved for the preference, you should set the value of the preference to defaultValue.
| Parameters | |
|---|---|
defaultValue: Any! |
The default value for the preference if set, otherwise |