# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: XML Attrs | Inherited XML Attrs | Inherited Constants | Ctors | Methods | Protected Methods | Inherited Methods

# MultiSelectListPreference

`public class MultiSelectListPreference`
`` `` `extends DialogPreference` ``

java.lang.Object
↳ | android.preference.Preference
| ↳ | android.preference.DialogPreference
|  | ↳ | android.preference.MultiSelectListPreference

This class is deprecated.
Use the AndroidX Preference Library for consistent behavior across all devices. For more information on using the AndroidX Preference Library see Settings.

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
From class `android.preference.DialogPreference`
`android:dialogIcon` | The icon for the dialog.
`android:dialogLayout` | A layout to be used as the content View for the dialog.
`android:dialogMessage` | The message in the dialog.
`android:dialogTitle` | The title in the dialog.
`android:negativeButtonText` | The negative button text for the dialog.
`android:positiveButtonText` | The positive button text for the dialog.
From class `android.preference.Preference`
`android:defaultValue` | The default value for the preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.
`android:dependency` | The key of another Preference that this Preference will depend on.
`android:enabled` | Whether the Preference is enabled.
`android:fragment` | When used inside of a modern PreferenceActivity, this declares a new PreferenceFragment to be shown when the user selects this item.
`android:icon` | The optional icon for the preference.
`android:iconSpaceReserved` | Whether the space for the preference icon view will be reserved.
`android:key` | The key to store the Preference value.
`android:layout` | The layout for the Preference in a PreferenceActivity screen.
`android:order` | The order for the Preference (lower values are to be ordered first).
`android:persistent` | Whether the Preference stores its value to the storage.
`android:recycleEnabled` | Whether the preference has enabled to have its view recycled when used in the list view.
`android:selectable` | Whether the Preference is selectable.
`android:shouldDisableView` | Whether the view of this Preference should be disabled when this Preference is disabled.
`android:singleLineTitle` | Whether to use single line for the preference title text.
`android:summary` | The summary for the Preference.
`android:title` | The title for the Preference.
`android:widgetLayout` | The layout for the controllable widget portion of a Preference.

### Inherited constants
From class `android.preference.Preference`
`int` | `DEFAULT_ORDER` Specify for `setOrder(int)` if a specific order is not required.

### Public constructors
`MultiSelectListPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)`
`MultiSelectListPreference(Context context, AttributeSet attrs, int defStyleAttr)`
`MultiSelectListPreference(Context context, AttributeSet attrs)`
`MultiSelectListPreference(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[]` | `getEntryValues()` Returns the array of values to be saved for the preference.
`Set<String>` | `getValues()` Retrieves the current 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` | `setValues(Set<String> values)` Sets the value of the key.

### Protected methods
`void` | `onDialogClosed(boolean positiveResult)` Called when the dialog is dismissed and should be used to save data to the `SharedPreferences`.
`Object` | `onGetDefaultValue(TypedArray a, int index)` Called when a Preference is being inflated and the default value attribute needs to be read.
`void` | `onPrepareDialogBuilder(AlertDialog.Builder builder)` Prepares the dialog builder to be shown when the preference is clicked.
`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(boolean restoreValue, Object defaultValue)` Implement this to set the initial value of the Preference.

### Inherited methods
From class `android.preference.DialogPreference`
`Dialog` | `getDialog()` Gets the dialog that is shown by this preference.
`Drawable` | `getDialogIcon()` Returns the icon to be shown on subsequent dialogs.
`int` | `getDialogLayoutResource()` Returns the layout resource that is used as the content View for subsequent dialogs.
`CharSequence` | `getDialogMessage()` Returns the message to be shown on subsequent dialogs.
`CharSequence` | `getDialogTitle()` Returns the title to be shown on subsequent dialogs.
`CharSequence` | `getNegativeButtonText()` Returns the text of the negative button to be shown on subsequent dialogs.
`CharSequence` | `getPositiveButtonText()` Returns the text of the positive button to be shown on subsequent dialogs.
`void` | `onActivityDestroy()` See Activity's onDestroy.
`void` | `onBindDialogView(View view)` Binds views in the content View of the dialog to data.
`void` | `onClick()` Processes a click on the preference.
`void` | `onClick(DialogInterface dialog, int which)` This method will be invoked when a button in the dialog is clicked.
`View` | `onCreateDialogView()` Creates the content view for the dialog (if a custom content view is required).
`void` | `onDialogClosed(boolean positiveResult)` Called when the dialog is dismissed and should be used to save data to the `SharedPreferences`.
`void` | `onDismiss(DialogInterface dialog)` This method will be invoked when the dialog is dismissed.
`void` | `onPrepareDialogBuilder(AlertDialog.Builder builder)` Prepares the dialog builder to be shown when the preference is clicked.
`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` | `setDialogIcon(int dialogIconRes)` Sets the icon (resource ID) of the dialog.
`void` | `setDialogIcon(Drawable dialogIcon)` Sets the icon of the dialog.
`void` | `setDialogLayoutResource(int dialogLayoutResId)` Sets the layout resource that is inflated as the `View` to be shown as the content View of subsequent dialogs.
`void` | `setDialogMessage(CharSequence dialogMessage)` Sets the message of the dialog.
`void` | `setDialogMessage(int dialogMessageResId)`
`void` | `setDialogTitle(int dialogTitleResId)`
`void` | `setDialogTitle(CharSequence dialogTitle)` Sets the title of the dialog.
`void` | `setNegativeButtonText(CharSequence negativeButtonText)` Sets the text of the negative button of the dialog.
`void` | `setNegativeButtonText(int negativeButtonTextResId)`
`void` | `setPositiveButtonText(int positiveButtonTextResId)`
`void` | `setPositiveButtonText(CharSequence positiveButtonText)` Sets the text of the positive button of the dialog.
`void` | `showDialog(Bundle state)` Shows the dialog associated with this Preference.
From class `android.preference.Preference`
`boolean` | `callChangeListener(Object newValue)` Call this method after the user changes the preference, but before the internal state is set.
`int` | `compareTo(Preference another)` Compares Preference objects based on order (if set), otherwise alphabetically on the titles.
`Preference` | `findPreferenceInHierarchy(String key)` Finds a Preference in this hierarchy (the whole thing, even above/below your `PreferenceScreen` screen break) with the given key.
`Context` | `getContext()` Returns the `Context` of this Preference.
`String` | `getDependency()` Returns the key of the dependency on this Preference.
`SharedPreferences.Editor` | `getEditor()` Returns an `SharedPreferences.Editor` where this Preference can save its value(s).
`Bundle` | `getExtras()` Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one.
`String` | `getFragment()` Return the fragment class name associated with this Preference.
`Drawable` | `getIcon()` Returns the icon of this Preference.
`Intent` | `getIntent()` Return the `Intent` associated with this Preference.
`String` | `getKey()` Gets the key for this Preference, which is also the key used for storing values into `SharedPreferences` or `PreferenceDataStore`.
`int` | `getLayoutResource()` Gets the layout resource that will be shown as the `View` for this Preference.
`Preference.OnPreferenceChangeListener` | `getOnPreferenceChangeListener()` Returns the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).
`Preference.OnPreferenceClickListener` | `getOnPreferenceClickListener()` Returns the callback to be invoked when this Preference is clicked.
`int` | `getOrder()` Gets the order of this Preference with respect to other Preference objects on the same level.
`PreferenceGroup` | `getParent()` Returns the `PreferenceGroup` which is this Preference assigned to or `null` if this preference is not assigned to any group or is a root Preference.
`boolean` | `getPersistedBoolean(boolean defaultReturnValue)` Attempts to get a persisted boolean if this Preference is persistent.
`float` | `getPersistedFloat(float defaultReturnValue)` Attempts to get a persisted float if this Preference is persistent.
`int` | `getPersistedInt(int defaultReturnValue)` Attempts to get a persisted int if this Preference is persistent.
`long` | `getPersistedLong(long defaultReturnValue)` Attempts to get a persisted long if this Preference is persistent.
`String` | `getPersistedString(String defaultReturnValue)` Attempts to get a persisted String if this Preference is persistent.
`Set<String>` | `getPersistedStringSet(Set<String> defaultReturnValue)` Attempts to get a persisted set of Strings if this Preference is persistent.
`PreferenceDataStore` | `getPreferenceDataStore()` Returns `PreferenceDataStore` used by this Preference.
`PreferenceManager` | `getPreferenceManager()` Gets the `PreferenceManager` that manages this Preference object's tree.
`SharedPreferences` | `getSharedPreferences()` Returns the `SharedPreferences` where this Preference can read its value(s).
`boolean` | `getShouldDisableView()` Checks whether this Preference should disable its view when it's action is disabled.
`CharSequence` | `getSummary()` Returns the summary of this Preference.
`CharSequence` | `getTitle()` Returns the title of this Preference.
`int` | `getTitleRes()` Returns the title resource ID of this Preference.
`View` | `getView(View convertView, ViewGroup parent)` Gets the View that will be shown in the `PreferenceActivity`.
`int` | `getWidgetLayoutResource()` Gets the layout resource for the controllable widget portion of this Preference.
`boolean` | `hasKey()` Checks whether this Preference has a valid key.
`boolean` | `isEnabled()` Checks whether this Preference should be enabled in the list.
`boolean` | `isIconSpaceReserved()` Gets whether the space this preference icon view is reserved.
`boolean` | `isPersistent()` Checks whether this Preference is persistent.
`boolean` | `isRecycleEnabled()` Checks whether this Preference has enabled to have its view recycled when used in the list view.
`boolean` | `isSelectable()` Checks whether this Preference should be selectable in the list.
`boolean` | `isSingleLineTitle()` Gets whether the title of this preference is constrained to a single line.
`void` | `notifyChanged()` Should be called when the data of this `Preference` has changed.
`void` | `notifyDependencyChange(boolean disableDependents)` Notifies any listening dependents of a change that affects the dependency.
`void` | `notifyHierarchyChanged()` Should be called when a Preference has been added/removed from this group, or the ordering should be re-evaluated.
`void` | `onAttachedToActivity()` Called when the Preference hierarchy has been attached to the `PreferenceActivity`.
`void` | `onAttachedToHierarchy(PreferenceManager preferenceManager)` Called when this Preference has been attached to a Preference hierarchy.
`void` | `onBindView(View view)` Binds the created View to the data for this Preference.
`void` | `onClick()` Processes a click on the preference.
`View` | `onCreateView(ViewGroup parent)` Creates the View to be shown for this Preference in the `PreferenceActivity`.
`void` | `onDependencyChanged(Preference dependency, boolean disableDependent)` Called when the dependency changes.
`Object` | `onGetDefaultValue(TypedArray a, int index)` Called when a Preference is being inflated and the default value attribute needs to be read.
`void` | `onParentChanged(Preference parent, boolean disableChild)` Called when the implicit parent dependency changes.
`void` | `onPrepareForRemoval()` Called when this Preference is being removed from the hierarchy.
`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(boolean restorePersistedValue, Object defaultValue)` Implement this to set the initial value of the Preference.
`Bundle` | `peekExtras()` Return the extras Bundle object associated with this preference, returning `null` if there is not currently one.
`boolean` | `persistBoolean(boolean value)` Attempts to persist a boolean if this Preference is persistent.
`boolean` | `persistFloat(float value)` Attempts to persist a long if this Preference is persistent.
`boolean` | `persistInt(int value)` Attempts to persist an int if this Preference is persistent.
`boolean` | `persistLong(long value)` Attempts to persist a long if this Preference is persistent.
`boolean` | `persistString(String value)` Attempts to persist a String if this Preference is persistent.
`boolean` | `persistStringSet(Set<String> values)` Attempts to persist a set of Strings if this Preference is persistent.
`void` | `restoreHierarchyState(Bundle container)` Restore this Preference hierarchy's previously saved state from the given container.
`void` | `saveHierarchyState(Bundle container)` Store this Preference hierarchy's frozen state into the given container.
`void` | `setDefaultValue(Object defaultValue)` Sets the default value for this Preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.
`void` | `setDependency(String dependencyKey)` Sets the key of a Preference that this Preference will depend on.
`void` | `setEnabled(boolean enabled)` Sets whether this Preference is enabled.
`void` | `setFragment(String fragment)` Sets the class name of a fragment to be shown when this Preference is clicked.
`void` | `setIcon(Drawable icon)` Sets the icon for this Preference with a Drawable.
`void` | `setIcon(int iconResId)` Sets the icon for this Preference with a resource ID.
`void` | `setIconSpaceReserved(boolean iconSpaceReserved)` Sets whether to reserve the space of this Preference icon view when no icon is provided.
`void` | `setIntent(Intent intent)` Sets an `Intent` to be used for `Context#startActivity(Intent)` when this Preference is clicked.
`void` | `setKey(String key)` Sets the key for this Preference, which is used as a key to the `SharedPreferences` or `PreferenceDataStore`.
`void` | `setLayoutResource(int layoutResId)` Sets the layout resource that is inflated as the `View` to be shown for this Preference.
`void` | `setOnPreferenceChangeListener(Preference.OnPreferenceChangeListener onPreferenceChangeListener)` Sets the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).
`void` | `setOnPreferenceClickListener(Preference.OnPreferenceClickListener onPreferenceClickListener)` Sets the callback to be invoked when this Preference is clicked.
`void` | `setOrder(int order)` Sets the order of this Preference with respect to other Preference objects on the same level.
`void` | `setPersistent(boolean persistent)` Sets whether this Preference is persistent.
`void` | `setPreferenceDataStore(PreferenceDataStore dataStore)` Sets a `PreferenceDataStore` to be used by this Preference instead of using `SharedPreferences`.
`void` | `setRecycleEnabled(boolean enabled)` Sets whether this Preference has enabled to have its view recycled when used in the list view.
`void` | `setSelectable(boolean selectable)` Sets whether this Preference is selectable.
`void` | `setShouldDisableView(boolean shouldDisableView)` Sets whether this Preference should disable its view when it gets disabled.
`void` | `setSingleLineTitle(boolean singleLineTitle)` Sets whether to constrain the title of this Preference to a single line instead of letting it wrap onto multiple lines.
`void` | `setSummary(CharSequence summary)` Sets the summary for this Preference with a CharSequence.
`void` | `setSummary(int summaryResId)` Sets the summary for this Preference with a resource ID.
`void` | `setTitle(CharSequence title)` Sets the title for this Preference with a CharSequence.
`void` | `setTitle(int titleResId)` Sets the title for this Preference with a resource ID.
`void` | `setWidgetLayoutResource(int widgetLayoutResId)` Sets the layout for the controllable widget portion of this Preference.
`boolean` | `shouldCommit()` Returns whether the `Preference` should commit its saved value(s) in `getEditor()`.
`boolean` | `shouldDisableDependents()` Checks whether this preference's dependents should currently be disabled.
`boolean` | `shouldPersist()` Checks whether, at the given time this method is called, this Preference should store/restore its value(s) into the `SharedPreferences` or into `PreferenceDataStore` if assigned.
`String` | `toString()` Returns a string representation of the object.
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `android.content.DialogInterface.OnClickListener`
`abstract void` | `onClick(DialogInterface dialog, int which)` This method will be invoked when a button in the dialog is clicked.
From interface `android.content.DialogInterface.OnDismissListener`
`abstract void` | `onDismiss(DialogInterface dialog)` This method will be invoked when the dialog is dismissed.
From interface `android.preference.PreferenceManager.OnActivityDestroyListener`
`abstract void` | `onActivityDestroy()` See Activity's onDestroy.
From interface `java.lang.Comparable`
`abstract int` | `compareTo(Preference o)` Compares this object with the specified object for order.

## XML attributes

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

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

    public MultiSelectListPreference (Context context,
                    AttributeSet attrs,
                    int defStyleAttr,
                    int defStyleRes)

Parameters
`context` | `Context`
`attrs` | `AttributeSet`
`defStyleAttr` | `int`
`defStyleRes` | `int`

### MultiSelectListPreference

    public MultiSelectListPreference (Context context,
                    AttributeSet attrs,
                    int defStyleAttr)

Parameters
`context` | `Context`
`attrs` | `AttributeSet`
`defStyleAttr` | `int`

### MultiSelectListPreference

    public MultiSelectListPreference (Context context,
                    AttributeSet attrs)

Parameters
`context` | `Context`
`attrs` | `AttributeSet`

### MultiSelectListPreference

    public MultiSelectListPreference (Context context)

Parameters
`context` | `Context`

## Public methods

### findIndexOfValue

    public int findIndexOfValue (String value)

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

Parameters
`value` | `String`: The value whose index should be returned.

Returns
`int` | The index of the value, or -1 if not found.

### getEntries

    public CharSequence[] getEntries ()

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

Returns
`CharSequence[]` | The list as an array.

### getEntryValues

    public CharSequence[] getEntryValues ()

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

Returns
`CharSequence[]` | The array of values.

### getValues

    public Set<String> getValues ()

Retrieves the current value of the key.

Returns
`Set<String>` |

### setEntries

    public void setEntries (CharSequence[] entries)

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` | `CharSequence`: The entries.

See also:

- `setEntryValues(CharSequence[])`

### setEntries

    public void setEntries (int entriesResId)

Parameters
`entriesResId` | `int`: The entries array as a resource.

See also:

- `setEntries(CharSequence[])`

### setEntryValues

    public void setEntryValues (int entryValuesResId)

Parameters
`entryValuesResId` | `int`: The entry values array as a resource.

See also:

- `setEntryValues(CharSequence[])`

### setEntryValues

    public void setEntryValues (CharSequence[] entryValues)

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` | `CharSequence`: The array to be used as values to save for the preference.

### setValues

    public void setValues (Set<String> values)

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

Parameters
`values` | `Set`: The values to set for the key.

## Protected methods

### onDialogClosed

    protected void onDialogClosed (boolean positiveResult)

Called when the dialog is dismissed and should be used to save data to the `SharedPreferences`.

Parameters
`positiveResult` | `boolean`: Whether the positive button was clicked (true), or the negative button was clicked or the dialog was canceled (false).

### onGetDefaultValue

    protected Object onGetDefaultValue (TypedArray a,
                    int index)

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 `TypedArray#getString(int)`.

Parameters
`a` | `TypedArray`: The set of attributes.
`index` | `int`: The index of the default value attribute.

Returns
`Object` | The default value of this preference type.

### onPrepareDialogBuilder

    protected void onPrepareDialogBuilder (AlertDialog.Builder builder)

Prepares the dialog builder to be shown when the preference is clicked. Use this to set custom properties on the dialog.

Do not `AlertDialog.Builder#create()` or `AlertDialog.Builder#show()`.

Parameters
`builder` | `AlertDialog.Builder`

### onSaveInstanceState

    protected 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. 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 `null` if there is nothing interesting to save. The default implementation returns `null`.

### onSetInitialValue

    protected void onSetInitialValue (boolean restoreValue,
                    Object defaultValue)

Implement this to set the initial value of the Preference.

If restorePersistedValue is true, you should restore the Preference value from the `SharedPreferences`. If restorePersistedValue is false, you should set the Preference value to defaultValue that is given (and possibly store to SharedPreferences if `shouldPersist()` is true).

In case of using `PreferenceDataStore`, the restorePersistedValue is always `true`. But the default value (if provided) is set.

This may not always be called. One example is if it should not persist but there is no default value given.

Parameters
`restoreValue` | `boolean`: True to restore the persisted value; false to use the given defaultValue.
`defaultValue` | `Object`: The default value for this Preference. Only use this if restorePersistedValue is false.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*