androidx.preference


The Preference library allows you to build interactive settings screens, without needing to handle interacting with device storage or managing the user interface.

Interfaces

DialogPreference.TargetFragment

Interface for PreferenceFragmentCompats to implement to allow DialogPreferences to find the preference that launched the dialog.

EditTextPreference.OnBindEditTextListener

Interface definition for a callback to be invoked when the corresponding dialog view for this preference is bound.

Preference.OnPreferenceChangeListener

Interface definition for a callback to be invoked when the value of this Preference has been changed by the user and is about to be set and/or persisted.

Preference.OnPreferenceClickListener

Interface definition for a callback to be invoked when a Preference is clicked.

Preference.SummaryProvider

Interface definition for a callback to be invoked when the summary of this Preference is requested (typically when this preference is added to the hierarchy or its value is updated).

PreferenceFragment.OnPreferenceDisplayDialogCallback

Interface that the fragment's containing activity should implement to be able to process preference items that wish to display a dialog.

PreferenceFragment.OnPreferenceStartFragmentCallback

Interface that the fragment's containing activity should implement to be able to process preference items that wish to switch to a specified fragment.

PreferenceFragment.OnPreferenceStartScreenCallback

Interface that the fragment's containing activity should implement to be able to process preference items that wish to switch to a new screen of preferences.

PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback

Interface that the fragment's containing activity should implement to be able to process preference items that wish to display a dialog.

PreferenceFragmentCompat.OnPreferenceStartFragmentCallback

Interface that the fragment's containing activity should implement to be able to process preference items that wish to switch to a specified fragment.

PreferenceFragmentCompat.OnPreferenceStartScreenCallback

Interface that the fragment's containing activity should implement to be able to process preference items that wish to switch to a new screen of preferences.

PreferenceGroup.PreferencePositionCallback

Interface for PreferenceGroup adapters to implement so that scrollToPreference and scrollToPreference can determine the correct scroll position to request.

PreferenceManager.OnDisplayPreferenceDialogListener

Interface definition for a class that will be called when a Preference requests to display a dialog.

PreferenceManager.OnNavigateToScreenListener

Interface definition for a class that will be called when a PreferenceScreen requests navigation.

PreferenceManager.OnPreferenceTreeClickListener

Interface definition for a callback to be invoked when a Preference in the hierarchy rooted at this PreferenceScreen is clicked.

Classes

CheckBoxPreference

A Preference that provides checkbox widget functionality.

DialogPreference

A base class for Preferences that are dialog-based.

DropDownPreference

A ListPreference that presents the options in a drop down menu rather than a dialog.

EditTextPreference

A DialogPreference that shows a EditText in the dialog.

EditTextPreference.SimpleSummaryProvider

A simple androidx.preference.Preference.SummaryProvider implementation for an EditTextPreference.

EditTextPreferenceDialogFragment

This class is deprecated.

Use EditTextPreferenceDialogFragmentCompat instead

EditTextPreferenceDialogFragmentCompat
ListPreference

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

ListPreference.SimpleSummaryProvider

A simple androidx.preference.Preference.SummaryProvider implementation for a ListPreference.

ListPreferenceDialogFragment

This class is deprecated.

Use ListPreferenceDialogFragmentCompat instead

ListPreferenceDialogFragmentCompat
MultiSelectListPreference

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

MultiSelectListPreferenceDialogFragment

This class is deprecated.

Use MultiSelectListPreferenceDialogFragmentCompat instead

MultiSelectListPreferenceDialogFragmentCompat
Preference

The basic building block that represents an individual setting displayed to a user in the preference hierarchy.

Preference.BaseSavedState

A base class for managing the instance state of a Preference.

PreferenceCategory

A container that is used to group similar Preferences.

PreferenceDataStore

A data store interface to be implemented and provided to the Preference framework.

PreferenceDialogFragment

This class is deprecated.

Use PreferenceDialogFragmentCompat instead

PreferenceDialogFragmentCompat

Abstract base class which presents a dialog associated with a DialogPreference.

PreferenceFragment

This class is deprecated.

Use PreferenceFragmentCompat instead

PreferenceFragmentCompat

A PreferenceFragmentCompat is the entry point to using the Preference library.

PreferenceGroup

A container for multiple Preferences.

PreferenceHeaderFragmentCompat

PreferenceHeaderFragmentCompat implements a two-pane fragment for preferences.

PreferenceManager

Used to help create Preference hierarchies from activities or XML.

PreferenceManager.PreferenceComparisonCallback

Callback class to be used by the androidx.recyclerview.widget.RecyclerView.Adapter associated with the PreferenceScreen, used to determine when two Preference objects are semantically and visually the same.

PreferenceManager.SimplePreferenceComparisonCallback

A basic implementation of PreferenceComparisonCallback suitable for use with the default Preference classes.

PreferenceScreen

A top-level container that represents a settings screen.

PreferenceViewHolder

A RecyclerView.ViewHolder class which caches views associated with the default Preference layouts.

SeekBarPreference

Preference based on android.preference.SeekBarPreference but uses support preference as a base .

SwitchPreference

A Preference that provides a two-state toggleable option.

SwitchPreferenceCompat

A Preference that provides a two-state toggleable option.

TwoStatePreference

Common base class for preferences that have two selectable states, save a boolean value, and may have dependent preferences that are enabled/disabled based on the current state.

Extension functions summary

operator Boolean

Returns true if preference is found in this preference group.

inline Unit
PreferenceGroup.forEach(action: (preference: Preference) -> Unit)

Performs the given action on each preference in this preference group.

inline Unit
PreferenceGroup.forEachIndexed(
    action: (index: Int, preference: Preference) -> Unit
)

Performs the given action on each preference in this preference group, providing its sequential index.

operator Preference

Returns the preference at index.

inline operator T?

Returns the preference with key, or null if no preference with key is found.

inline Boolean

Returns true if this preference group contains no preferences.

inline Boolean

Returns true if this preference group contains one or more preferences.

operator Iterator<Preference>

Returns a MutableIterator over the preferences in this preference group.

inline operator Unit

Removes preference from this preference group.

inline operator Unit

Adds preference to this preference group.

Extension properties summary

Sequence<Preference>

Returns a Sequence over the preferences in this preference group.

Int

Returns the number of preferences in this preference group.

Extension functions

operator fun PreferenceGroup.contains(preference: Preference): Boolean

Returns true if preference is found in this preference group.

inline fun PreferenceGroup.forEach(action: (preference: Preference) -> Unit): Unit

Performs the given action on each preference in this preference group.

forEachIndexed

inline fun PreferenceGroup.forEachIndexed(
    action: (index: Int, preference: Preference) -> Unit
): Unit

Performs the given action on each preference in this preference group, providing its sequential index.

operator fun PreferenceGroup.get(index: Int): Preference

Returns the preference at index.

Throws
kotlin.IndexOutOfBoundsException

if index is less than 0 or greater than or equal to the count.

inline operator fun <T : Preference> PreferenceGroup.get(key: CharSequence): T?

Returns the preference with key, or null if no preference with key is found.

inline fun PreferenceGroup.isEmpty(): Boolean

Returns true if this preference group contains no preferences.

isNotEmpty

inline fun PreferenceGroup.isNotEmpty(): Boolean

Returns true if this preference group contains one or more preferences.

operator fun PreferenceGroup.iterator(): Iterator<Preference>

Returns a MutableIterator over the preferences in this preference group.

minusAssign

inline operator fun PreferenceGroup.minusAssign(preference: Preference): Unit

Removes preference from this preference group.

plusAssign

inline operator fun PreferenceGroup.plusAssign(preference: Preference): Unit

Adds preference to this preference group.

Extension properties

val PreferenceGroup.childrenSequence<Preference>

Returns a Sequence over the preferences in this preference group.

val PreferenceGroup.sizeInt

Returns the number of preferences in this preference group.