# PreferenceScreen

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:preference-v7:28.0.0-alpha1  
Summary:[Inherited XML Attrs](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#inhattrs)\|[Inherited Constants](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#inhconstants)\|[Methods](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#)  

# PreferenceScreen

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
PreferenceScreen
`  
`


``


``

extends `[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)`


``


`

|---|---|---|------------------------------------------------|
| java.lang.Object                                        ||||
| ↳ | [android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference) |||
|   | ↳ | [android.support.v7.preference.PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup) ||
|   |   | ↳ | android.support.v7.preference.PreferenceScreen |

<br />

*** ** * ** ***

Represents a top-level[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)that is the root of a Preference hierarchy. A[PreferenceFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat)points to an instance of this class to show the preferences. To instantiate this class, use[createPreferenceScreen(android.content.Context)](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager#createPreferenceScreen(android.content.Context)).

This class can appear in two places:
- When a[PreferenceFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat)points to this, it is used as the root and is not shown (only the contained preferences are shown).
- When it appears inside another preference hierarchy, it is shown and serves as the gateway to another screen of preferences (either by showing another screen of preferences as a[Dialog](https://developer.android.com/reference/android/app/Dialog.html)or via a[startActivity(android.content.Intent)](https://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent))from the[getIntent()](https://developer.android.com/reference/android/support/v7/preference/Preference#getIntent())). The children of this[PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)are NOT shown in the screen that this[PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)is shown in. Instead, a separate screen will be shown when this preference is clicked.

Here's an example XML layout of a PreferenceScreen:  

```
 <PreferenceScreen
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:key="first_preferencescreen">
 <CheckBoxPreference
 android:key="wifi enabled"
 android:title="WiFi" />
 <PreferenceScreen
 android:key="second_preferencescreen"
 android:title="WiFi settings">
 <CheckBoxPreference
 android:key="prefer wifi"
 android:title="Prefer WiFi" />
 ... other preferences here ...
 </PreferenceScreen>
 </PreferenceScreen> 
```

In this example, the "first_preferencescreen" will be used as the root of the hierarchy and given to a[PreferenceFragment](https://developer.android.com/reference/android/support/v14/preference/PreferenceFragment)or[PreferenceFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat). The first screen will show preferences "WiFi" (which can be used to quickly enable/disable WiFi) and "WiFi settings". The "WiFi settings" is the "second_preferencescreen" and when clicked will show another screen of preferences such as "Prefer WiFi" (and the other preferences that are children of the "second_preferencescreen" tag).  

### Developer Guides

For information about building a settings UI with Preferences, read the[Settings](https://developer.android.com/guide/topics/ui/settings)guide.

<br />

**See also:**

- [PreferenceCategory](https://developer.android.com/reference/android/support/v7/preference/PreferenceCategory)

## Summary

| ### Inherited XML attributes |
|------------------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#)From class` `[android.support.v7.preference.PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)` ` |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---| | [`PreferenceGroup_initialExpandedChildrenCount`](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#attr_PreferenceGroup_initialExpandedChildrenCount) |   | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |----------------------------------------------------------------------------------------------------------------------------------------------------------------------|---| | [`Preference_android_iconSpaceReserved`](https://developer.android.com/reference/android/support/v7/preference/Preference#attr_Preference_android_iconSpaceReserved) |   | | [`Preference_android_singleLineTitle`](https://developer.android.com/reference/android/support/v7/preference/Preference#attr_Preference_android_singleLineTitle)     |   | ||

|                                                                                                                                                                                                                                                                                                                                                                                                                                             ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |-------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int` | [DEFAULT_ORDER](https://developer.android.com/reference/android/support/v7/preference/Preference#DEFAULT_ORDER) Specify for[setOrder(int)](https://developer.android.com/reference/android/support/v7/preference/Preference#setOrder(int))if a specific order is not required. | |

|                                                                                                                                                                                                                                            ### Public methods                                                                                                                                                                                                                                            ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`    | ` `[setShouldUseGeneratedIds](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#setShouldUseGeneratedIds(boolean))`(boolean shouldUseGeneratedIds) ` Set whether the adapter created for this screen should attempt to use the preference IDs generated by[addPreference(Preference)](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#addPreference(android.support.v7.preference.Preference))as stable item IDs. |
| ` boolean` | ` `[shouldUseGeneratedIds](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#shouldUseGeneratedIds())`() ` See[setShouldUseGeneratedIds(boolean)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#setShouldUseGeneratedIds(boolean))                                                                                                                                                                             |

|                                                                                                                      ### Protected methods                                                                                                                       ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` boolean` | ` `[isOnSameScreenAsChildren](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#isOnSameScreenAsChildren())`() ` Whether this preference group should be shown on the same screen as its contained preferences. |
| ` void`    | ` `[onClick](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#onClick())`() ` Processes a click on the preference.                                                                                             |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#)From class` `[android.support.v7.preference.PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)` ` |---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                           | ` `[addItemFromInflater](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#addItemFromInflater(android.support.v7.preference.Preference))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` preference) ` Called by the inflater to add an item to this group.                                                                                                                                                                | | ` boolean`                                                                                        | ` `[addPreference](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#addPreference(android.support.v7.preference.Preference))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` preference) ` Adds a[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)at the correct position based on the preference's order.                                                                    | | ` void`                                                                                           | ` `[dispatchRestoreInstanceState](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#dispatchRestoreInstanceState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` container) ` Called by[restoreHierarchyState(Bundle)](https://developer.android.com/reference/android/support/v7/preference/Preference#restoreHierarchyState(android.os.Bundle))to retrieve the saved state for this Preference and its children.            | | ` void`                                                                                           | ` `[dispatchSaveInstanceState](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#dispatchSaveInstanceState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` container) ` Called by[saveHierarchyState(Bundle)](https://developer.android.com/reference/android/support/v7/preference/Preference#saveHierarchyState(android.os.Bundle))to store the instance for this Preference and its children.                              | | ` `[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference) | ` `[findPreference](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#findPreference(java.lang.CharSequence))`(CharSequence key) ` Finds a[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)based on its key.                                                                                                                                                                                                                     | | ` int`                                                                                            | ` `[getInitialExpandedChildrenCount](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#getInitialExpandedChildrenCount())`() ` Gets the maximal number of children that is initially shown.                                                                                                                                                                                                                                                                                   | | ` `[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference) | ` `[getPreference](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#getPreference(int))`(int index) ` Returns the[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)at a particular index.                                                                                                                                                                                                                                        | | ` int`                                                                                            | ` `[getPreferenceCount](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#getPreferenceCount())`() ` Returns the number of children[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)s.                                                                                                                                                                                                                                           | | ` boolean`                                                                                        | ` `[isOnSameScreenAsChildren](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#isOnSameScreenAsChildren())`() ` Whether this preference group should be shown on the same screen as its contained preferences.                                                                                                                                                                                                                                                               | | ` boolean`                                                                                        | ` `[isOrderingAsAdded](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#isOrderingAsAdded())`() ` Whether this group is ordering preferences in the order they are added.                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                           | ` `[notifyDependencyChange](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#notifyDependencyChange(boolean))`(boolean disableDependents) ` Notifies any listening dependents of a change that affects the dependency.                                                                                                                                                                                                                                                       | | ` void`                                                                                           | ` `[onAttached](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#onAttached())`() ` Called when the Preference hierarchy has been attached to the list of preferences.                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                           | ` `[onDetached](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#onDetached())`() ` Called when the Preference hierarchy has been detached from the list of preferences.                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                        | ` `[onPrepareAddPreference](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#onPrepareAddPreference(android.support.v7.preference.Preference))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` preference) ` Prepares a[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)to be added to the group.                                                                             | | ` void`                                                                                           | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#onRestoreInstanceState(android.os.Parcelable))`(`[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state) ` Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState()). | | ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)               | ` `[onSaveInstanceState](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#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`                                                                                           | ` `[removeAll](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#removeAll())`() ` Removes all[Preferences](https://developer.android.com/reference/android/support/v7/preference/Preference)from this group.                                                                                                                                                                                                                                                                 | | ` boolean`                                                                                        | ` `[removePreference](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#removePreference(android.support.v7.preference.Preference))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` preference) ` Removes a[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)from this group.                                                                                                   | | ` void`                                                                                           | ` `[setInitialExpandedChildrenCount](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#setInitialExpandedChildrenCount(int))`(int expandedCount) ` Sets the maximal number of children that are shown when the preference group is launched where the rest of the children will be hidden.                                                                                                                                                                                    | | ` void`                                                                                           | ` `[setOrderingAsAdded](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#setOrderingAsAdded(boolean))`(boolean orderingAsAdded) ` Whether to order the[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)children of this group as they are added.                                                                                                                                                                                | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#)From class` `[android.support.v7.preference.Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` ` |---------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` boolean`                                                                                                                                              | ` `[callChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#callChangeListener(java.lang.Object))`(Object newValue) ` Call this method after the user changes the preference, but before the internal state is set.                                                                                                                                                                                                                                                                                                                                  | | ` int`                                                                                                                                                  | ` `[compareTo](https://developer.android.com/reference/android/support/v7/preference/Preference#compareTo(android.support.v7.preference.Preference))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` another) ` Compares Preference objects based on order (if set), otherwise alphabetically on the titles.                                                                                                                                                                                                                                    | | ` `[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)                                                       | ` `[findPreferenceInHierarchy](https://developer.android.com/reference/android/support/v7/preference/Preference#findPreferenceInHierarchy(java.lang.String))`(String key) ` Finds a Preference in this hierarchy (the whole thing, even above/below your[PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)screen break) with the given key.                                                                                                                                                                                               | | ` `[Context](https://developer.android.com/reference/android/content/Context.html)                                                                      | ` `[getContext](https://developer.android.com/reference/android/support/v7/preference/Preference#getContext())`() ` Returns the[Context](https://developer.android.com/reference/android/content/Context.html)of this Preference.                                                                                                                                                                                                                                                                                                                                                                 | | ` String`                                                                                                                                               | ` `[getDependency](https://developer.android.com/reference/android/support/v7/preference/Preference#getDependency())`() ` Returns the key of the dependency on this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                             | ` `[getExtras](https://developer.android.com/reference/android/support/v7/preference/Preference#getExtras())`() ` Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one.                                                                                                                                                                                                                                                                                                                                                            | | ` String`                                                                                                                                               | ` `[getFragment](https://developer.android.com/reference/android/support/v7/preference/Preference#getFragment())`() ` Return the fragment class name associated with this Preference.                                                                                                                                                                                                                                                                                                                                                                                                             | | ` `[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)                                                          | ` `[getIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#getIcon())`() ` Returns the icon of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` `[Intent](https://developer.android.com/reference/android/content/Intent.html)                                                                        | ` `[getIntent](https://developer.android.com/reference/android/support/v7/preference/Preference#getIntent())`() ` Return the[Intent](https://developer.android.com/reference/android/content/Intent.html)associated with this Preference.                                                                                                                                                                                                                                                                                                                                                         | | ` String`                                                                                                                                               | ` `[getKey](https://developer.android.com/reference/android/support/v7/preference/Preference#getKey())`() ` Gets the key for this Preference, which is also the key used for storing values into[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore).                                                                                                                                                                            | | ` final int`                                                                                                                                            | ` `[getLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#getLayoutResource())`() ` Gets the layout resource that will be shown as the[View](https://developer.android.com/reference/android/view/View.html)for this Preference.                                                                                                                                                                                                                                                                                                                    | | ` `[Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceChangeListener) | ` `[getOnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#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](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)   | ` `[getOnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference#getOnPreferenceClickListener())`() ` Returns the callback to be invoked when this Preference is clicked.                                                                                                                                                                                                                                                                                                                                                                       | | ` int`                                                                                                                                                  | ` `[getOrder](https://developer.android.com/reference/android/support/v7/preference/Preference#getOrder())`() ` Gets the order of this Preference with respect to other Preference objects on the same level.                                                                                                                                                                                                                                                                                                                                                                                     | | ` `[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)                                             | ` `[getParent](https://developer.android.com/reference/android/support/v7/preference/Preference#getParent())`() ` Returns the[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/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](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedBoolean(boolean))`(boolean defaultReturnValue) ` Attempts to get a persisted[Boolean](https://developer.android.com/reference/java/lang/Boolean)if this Preference is persistent.                                                                                                                                                                                                                                                                                           | | ` float`                                                                                                                                                | ` `[getPersistedFloat](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedFloat(float))`(float defaultReturnValue) ` Attempts to get a persisted[Float](https://developer.android.com/reference/java/lang/Float)if this Preference is persistent.                                                                                                                                                                                                                                                                                                       | | ` int`                                                                                                                                                  | ` `[getPersistedInt](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedInt(int))`(int defaultReturnValue) ` Attempts to get a persisted[Integer](https://developer.android.com/reference/java/lang/Integer)if this Preference is persistent.                                                                                                                                                                                                                                                                                                           | | ` long`                                                                                                                                                 | ` `[getPersistedLong](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedLong(long))`(long defaultReturnValue) ` Attempts to get a persisted[Long](https://developer.android.com/reference/java/lang/Long)if this Preference is persistent.                                                                                                                                                                                                                                                                                                             | | ` String`                                                                                                                                               | ` `[getPersistedString](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedString(java.lang.String))`(String defaultReturnValue) ` Attempts to get a persisted set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                         | | ` Set<String>`                                                                                                                                          | ` `[getPersistedStringSet](https://developer.android.com/reference/android/support/v7/preference/Preference#getPersistedStringSet(java.util.Set<java.lang.String>))`(Set<String> defaultReturnValue) ` Attempts to get a persisted set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                               | | ` `[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)                                     | ` `[getPreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/Preference#getPreferenceDataStore())`() ` Returns[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)used by this Preference.                                                                                                                                                                                                                                                                                                       | | ` `[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)                                         | ` `[getPreferenceManager](https://developer.android.com/reference/android/support/v7/preference/Preference#getPreferenceManager())`() ` Gets the[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)that manages this Preference object's tree.                                                                                                                                                                                                                                                                                           | | ` `[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)                                                  | ` `[getSharedPreferences](https://developer.android.com/reference/android/support/v7/preference/Preference#getSharedPreferences())`() ` Returns the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)where this Preference can read its value(s).                                                                                                                                                                                                                                                                                                | | ` boolean`                                                                                                                                              | ` `[getShouldDisableView](https://developer.android.com/reference/android/support/v7/preference/Preference#getShouldDisableView())`() ` Checks whether this Preference should disable its view when it's action is disabled.                                                                                                                                                                                                                                                                                                                                                                      | | ` CharSequence`                                                                                                                                         | ` `[getSummary](https://developer.android.com/reference/android/support/v7/preference/Preference#getSummary())`() ` Returns the summary of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` CharSequence`                                                                                                                                         | ` `[getTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#getTitle())`() ` Returns the title of this Preference.                                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` final int`                                                                                                                                            | ` `[getWidgetLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#getWidgetLayoutResource())`() ` Gets the layout resource for the controllable widget portion of this Preference.                                                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[hasKey](https://developer.android.com/reference/android/support/v7/preference/Preference#hasKey())`() ` Checks whether this Preference has a valid key.                                                                                                                                                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                                                                              | ` `[isEnabled](https://developer.android.com/reference/android/support/v7/preference/Preference#isEnabled())`() ` Checks whether this Preference should be enabled in the list.                                                                                                                                                                                                                                                                                                                                                                                                                   | | ` boolean`                                                                                                                                              | ` `[isIconSpaceReserved](https://developer.android.com/reference/android/support/v7/preference/Preference#isIconSpaceReserved())`() ` Returns whether the space of this preference icon view is reserved.                                                                                                                                                                                                                                                                                                                                                                                         | | ` boolean`                                                                                                                                              | ` `[isPersistent](https://developer.android.com/reference/android/support/v7/preference/Preference#isPersistent())`() ` Checks whether this Preference is persistent.                                                                                                                                                                                                                                                                                                                                                                                                                             | | ` boolean`                                                                                                                                              | ` `[isSelectable](https://developer.android.com/reference/android/support/v7/preference/Preference#isSelectable())`() ` Checks whether this Preference should be selectable in the list.                                                                                                                                                                                                                                                                                                                                                                                                          | | ` boolean`                                                                                                                                              | ` `[isSingleLineTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#isSingleLineTitle())`() ` Gets whether the title of this preference is constrained to a single line.                                                                                                                                                                                                                                                                                                                                                                                      | | ` final boolean`                                                                                                                                        | ` `[isVisible](https://developer.android.com/reference/android/support/v7/preference/Preference#isVisible())`() ` Checks whether this preference should be visible to the user in the list.                                                                                                                                                                                                                                                                                                                                                                                                       | | ` void`                                                                                                                                                 | ` `[notifyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyChanged())`() ` Should be called when the data of this[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)has changed.                                                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                                                                 | ` `[notifyDependencyChange](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyDependencyChange(boolean))`(boolean disableDependents) ` Notifies any listening dependents of a change that affects the dependency.                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[notifyHierarchyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#notifyHierarchyChanged())`() ` Should be called when a Preference has been added/removed from this group, or the ordering should be re-evaluated.                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[onAttached](https://developer.android.com/reference/android/support/v7/preference/Preference#onAttached())`() ` Called when the Preference hierarchy has been attached to the list of preferences.                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[onAttachedToHierarchy](https://developer.android.com/reference/android/support/v7/preference/Preference#onAttachedToHierarchy(android.support.v7.preference.PreferenceManager))`(`[PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)` preferenceManager) ` Called when this Preference has been attached to a Preference hierarchy.                                                                                                                                                                                                 | | ` void`                                                                                                                                                 | ` `[onBindViewHolder](https://developer.android.com/reference/android/support/v7/preference/Preference#onBindViewHolder(android.support.v7.preference.PreferenceViewHolder))`(`[PreferenceViewHolder](https://developer.android.com/reference/android/support/v7/preference/PreferenceViewHolder)` holder) ` Binds the created View to the data for this Preference.                                                                                                                                                                                                                              | | ` void`                                                                                                                                                 | ` `[onClick](https://developer.android.com/reference/android/support/v7/preference/Preference#onClick())`() ` Processes a click on the preference.                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                                 | ` `[onDependencyChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#onDependencyChanged(android.support.v7.preference.Preference, boolean))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` dependency, boolean disableDependent) ` Called when the dependency changes.                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[onDetached](https://developer.android.com/reference/android/support/v7/preference/Preference#onDetached())`() ` Called when the Preference hierarchy has been detached from the list of preferences.                                                                                                                                                                                                                                                                                                                                                                                          | | ` Object`                                                                                                                                               | ` `[onGetDefaultValue](https://developer.android.com/reference/android/support/v7/preference/Preference#onGetDefaultValue(android.content.res.TypedArray, int))`(`[TypedArray](https://developer.android.com/reference/android/content/res/TypedArray.html)` a, int index) ` Called when a Preference is being inflated and the default value attribute needs to be read.                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[onInitializeAccessibilityNodeInfo](https://developer.android.com/reference/android/support/v7/preference/Preference#onInitializeAccessibilityNodeInfo(android.support.v4.view.accessibility.AccessibilityNodeInfoCompat))`(`[AccessibilityNodeInfoCompat](https://developer.android.com/reference/android/support/v4/view/accessibility/AccessibilityNodeInfoCompat)` info) ` Initializes an[AccessibilityNodeInfo](https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html)with information about the View for this Preference.                        | | ` void`                                                                                                                                                 | ` `[onParentChanged](https://developer.android.com/reference/android/support/v7/preference/Preference#onParentChanged(android.support.v7.preference.Preference, boolean))`(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` parent, boolean disableChild) ` Called when the implicit parent dependency changes.                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[onPrepareForRemoval](https://developer.android.com/reference/android/support/v7/preference/Preference#onPrepareForRemoval())`() ` Called when this Preference is being removed from the hierarchy.                                                                                                                                                                                                                                                                                                                                                                                            | | ` void`                                                                                                                                                 | ` `[onRestoreInstanceState](https://developer.android.com/reference/android/support/v7/preference/Preference#onRestoreInstanceState(android.os.Parcelable))`(`[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)` state) ` Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/Preference#onSaveInstanceState()).                                                                                      | | ` `[Parcelable](https://developer.android.com/reference/android/os/Parcelable.html)                                                                     | ` `[onSaveInstanceState](https://developer.android.com/reference/android/support/v7/preference/Preference#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](https://developer.android.com/reference/android/support/v7/preference/Preference#onSetInitialValue(boolean, java.lang.Object))`(boolean restorePersistedValue, Object defaultValue) ` Implement this to set the initial value of the Preference.                                                                                                                                                                                                                                                                                                                           | | ` `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)                                                                             | ` `[peekExtras](https://developer.android.com/reference/android/support/v7/preference/Preference#peekExtras())`() ` Return the extras Bundle object associated with this preference, returning null if there is not currently one.                                                                                                                                                                                                                                                                                                                                                                | | ` boolean`                                                                                                                                              | ` `[persistBoolean](https://developer.android.com/reference/android/support/v7/preference/Preference#persistBoolean(boolean))`(boolean value) ` Attempts to persist a[Boolean](https://developer.android.com/reference/java/lang/Boolean)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                        | | ` boolean`                                                                                                                                              | ` `[persistFloat](https://developer.android.com/reference/android/support/v7/preference/Preference#persistFloat(float))`(float value) ` Attempts to persist a[Float](https://developer.android.com/reference/java/lang/Float)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[persistInt](https://developer.android.com/reference/android/support/v7/preference/Preference#persistInt(int))`(int value) ` Attempts to persist an[Integer](https://developer.android.com/reference/java/lang/Integer)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                       | | ` boolean`                                                                                                                                              | ` `[persistLong](https://developer.android.com/reference/android/support/v7/preference/Preference#persistLong(long))`(long value) ` Attempts to persist a[Long](https://developer.android.com/reference/java/lang/Long)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                          | | ` boolean`                                                                                                                                              | ` `[persistString](https://developer.android.com/reference/android/support/v7/preference/Preference#persistString(java.lang.String))`(String value) ` Attempts to persist a[String](https://developer.android.com/reference/java/lang/String)if this Preference is persistent.                                                                                                                                                                                                                                                                                                                    | | ` boolean`                                                                                                                                              | ` `[persistStringSet](https://developer.android.com/reference/android/support/v7/preference/Preference#persistStringSet(java.util.Set<java.lang.String>))`(Set<String> values) ` Attempts to persist a set of Strings if this Preference is persistent.                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[restoreHierarchyState](https://developer.android.com/reference/android/support/v7/preference/Preference#restoreHierarchyState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` container) ` Restore this Preference hierarchy's previously saved state from the given container.                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[saveHierarchyState](https://developer.android.com/reference/android/support/v7/preference/Preference#saveHierarchyState(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` container) ` Store this Preference hierarchy's frozen state into the given container.                                                                                                                                                                                                                                                                                 | | ` void`                                                                                                                                                 | ` `[setDefaultValue](https://developer.android.com/reference/android/support/v7/preference/Preference#setDefaultValue(java.lang.Object))`(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](https://developer.android.com/reference/android/support/v7/preference/Preference#setDependency(java.lang.String))`(String dependencyKey) ` Sets the key of a Preference that this Preference will depend on.                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setEnabled](https://developer.android.com/reference/android/support/v7/preference/Preference#setEnabled(boolean))`(boolean enabled) ` Sets whether this Preference is enabled.                                                                                                                                                                                                                                                                                                                                                                                                                | | ` void`                                                                                                                                                 | ` `[setFragment](https://developer.android.com/reference/android/support/v7/preference/Preference#setFragment(java.lang.String))`(String fragment) ` Sets the class name of a fragment to be shown when this Preference is clicked.                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#setIcon(android.graphics.drawable.Drawable))`(`[Drawable](https://developer.android.com/reference/android/graphics/drawable/Drawable.html)` icon) ` Sets the icon for this Preference with a Drawable.                                                                                                                                                                                                                                                                                              | | ` void`                                                                                                                                                 | ` `[setIcon](https://developer.android.com/reference/android/support/v7/preference/Preference#setIcon(int))`(int iconResId) ` Sets the icon for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setIconSpaceReserved](https://developer.android.com/reference/android/support/v7/preference/Preference#setIconSpaceReserved(boolean))`(boolean iconSpaceReserved) ` Sets whether to reserve the space of this Preference icon view when no icon is provided.                                                                                                                                                                                                                                                                                                                                  | | ` void`                                                                                                                                                 | ` `[setIntent](https://developer.android.com/reference/android/support/v7/preference/Preference#setIntent(android.content.Intent))`(`[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` Sets an[Intent](https://developer.android.com/reference/android/content/Intent.html)to be used for[startActivity(Intent)](https://developer.android.com/reference/android/content/Context.html#startActivity(android.content.Intent))when this Preference is clicked.                                                                                               | | ` void`                                                                                                                                                 | ` `[setKey](https://developer.android.com/reference/android/support/v7/preference/Preference#setKey(java.lang.String))`(String key) ` Sets the key for this Preference, which is used as a key to the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore).                                                                                                                                                                       | | ` void`                                                                                                                                                 | ` `[setLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#setLayoutResource(int))`(int layoutResId) ` Sets the layout resource that is inflated as the[View](https://developer.android.com/reference/android/view/View.html)to be shown for this Preference.                                                                                                                                                                                                                                                                                        | | ` void`                                                                                                                                                 | ` `[setOnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference#setOnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener))`(`[Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/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](https://developer.android.com/reference/android/support/v7/preference/Preference#setOnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener))`(`[Preference.OnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)` onPreferenceClickListener) ` Sets the callback to be invoked when this Preference is clicked.                                                                                                                          | | ` void`                                                                                                                                                 | ` `[setOrder](https://developer.android.com/reference/android/support/v7/preference/Preference#setOrder(int))`(int order) ` Sets the order of this Preference with respect to other Preference objects on the same level.                                                                                                                                                                                                                                                                                                                                                                         | | ` void`                                                                                                                                                 | ` `[setPersistent](https://developer.android.com/reference/android/support/v7/preference/Preference#setPersistent(boolean))`(boolean persistent) ` Sets whether this Preference is persistent.                                                                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[setPreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/Preference#setPreferenceDataStore(android.support.v7.preference.PreferenceDataStore))`(`[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)` dataStore) ` Sets a[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)to be used by this Preference instead of using[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html). | | ` void`                                                                                                                                                 | ` `[setSelectable](https://developer.android.com/reference/android/support/v7/preference/Preference#setSelectable(boolean))`(boolean selectable) ` Sets whether this Preference is selectable.                                                                                                                                                                                                                                                                                                                                                                                                    | | ` void`                                                                                                                                                 | ` `[setShouldDisableView](https://developer.android.com/reference/android/support/v7/preference/Preference#setShouldDisableView(boolean))`(boolean shouldDisableView) ` Sets whether this Preference should disable its view when it gets disabled.                                                                                                                                                                                                                                                                                                                                               | | ` void`                                                                                                                                                 | ` `[setSingleLineTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setSingleLineTitle(boolean))`(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](https://developer.android.com/reference/android/support/v7/preference/Preference#setSummary(java.lang.CharSequence))`(CharSequence summary) ` Sets the summary for this Preference with a CharSequence.                                                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[setSummary](https://developer.android.com/reference/android/support/v7/preference/Preference#setSummary(int))`(int summaryResId) ` Sets the summary for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setTitle(java.lang.CharSequence))`(CharSequence title) ` Sets the title for this Preference with a CharSequence.                                                                                                                                                                                                                                                                                                                                                                                   | | ` void`                                                                                                                                                 | ` `[setTitle](https://developer.android.com/reference/android/support/v7/preference/Preference#setTitle(int))`(int titleResId) ` Sets the title for this Preference with a resource ID.                                                                                                                                                                                                                                                                                                                                                                                                           | | ` void`                                                                                                                                                 | ` `[setViewId](https://developer.android.com/reference/android/support/v7/preference/Preference#setViewId(int))`(int viewId) ` Set the ID that will be assigned to the overall View representing this preference, once bound.                                                                                                                                                                                                                                                                                                                                                                     | | ` final void`                                                                                                                                           | ` `[setVisible](https://developer.android.com/reference/android/support/v7/preference/Preference#setVisible(boolean))`(boolean visible) ` Sets whether this preference should be visible in the list.                                                                                                                                                                                                                                                                                                                                                                                             | | ` void`                                                                                                                                                 | ` `[setWidgetLayoutResource](https://developer.android.com/reference/android/support/v7/preference/Preference#setWidgetLayoutResource(int))`(int widgetLayoutResId) ` Sets the layout for the controllable widget portion of this Preference.                                                                                                                                                                                                                                                                                                                                                     | | ` boolean`                                                                                                                                              | ` `[shouldDisableDependents](https://developer.android.com/reference/android/support/v7/preference/Preference#shouldDisableDependents())`() ` Checks whether this preference's dependents should currently be disabled.                                                                                                                                                                                                                                                                                                                                                                           | | ` boolean`                                                                                                                                              | ` `[shouldPersist](https://developer.android.com/reference/android/support/v7/preference/Preference#shouldPersist())`() ` Checks whether, at the given time this method is called, this Preference should store/restore its value(s) into the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html)or into[PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)if assigned.                                                                                                               | | ` String`                                                                                                                                               | ` `[toString](https://developer.android.com/reference/android/support/v7/preference/Preference#toString())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#)From interface` java.lang.Comparable ` |-----------------|----------------------------------------------------------------------------------------------------------------------| | ` abstract int` | ` compareTo(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` arg0) ` | ||

## Public methods

### setShouldUseGeneratedIds

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setShouldUseGeneratedIds (boolean shouldUseGeneratedIds)
```

Set whether the adapter created for this screen should attempt to use the preference IDs generated by[addPreference(Preference)](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#addPreference(android.support.v7.preference.Preference))as stable item IDs. Setting this to false can suppress unwanted animations if[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)objects are frequently removed from and re-added to their containing[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup).

This method may only be called when the preference screen is not attached to the hierarchy.

Default value is`true`.

<br />

|                                                                      Parameters                                                                       ||
|-------------------------|------------------------------------------------------------------------------------------------------------------------------|
| `shouldUseGeneratedIds` | `boolean`:`true`if the adapter should use the preference ID as a stable ID, or`false`to disable the use of stable IDs <br /> |

### shouldUseGeneratedIds

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean shouldUseGeneratedIds ()
```

See[setShouldUseGeneratedIds(boolean)](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen#setShouldUseGeneratedIds(boolean))

<br />

|                                                                                                                                    Returns                                                                                                                                    ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`if the adapter should use the preference IDs generated by[addPreference(Preference)](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#addPreference(android.support.v7.preference.Preference))as stable item IDs <br /> |

## Protected methods

### isOnSameScreenAsChildren

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean isOnSameScreenAsChildren ()
```

Whether this preference group should be shown on the same screen as its contained preferences.

<br />

|                                                  Returns                                                   ||
|-----------|-------------------------------------------------------------------------------------------------|
| `boolean` | True if the contained preferences should be shown on the same screen as this preference. <br /> |

### onClick

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onClick ()
```

Processes a click on the preference. This includes saving the value to the[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html). However, the overridden method should call[callChangeListener(Object)](https://developer.android.com/reference/android/support/v7/preference/Preference#callChangeListener(java.lang.Object))to make sure the client wants to update the preference's state with the new value.

<br />

-

  ## Interfaces

  - [DialogPreference.TargetFragment](https://developer.android.com/reference/android/support/v7/preference/DialogPreference.TargetFragment)
  - [Preference.OnPreferenceChangeListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceChangeListener)
  - [Preference.OnPreferenceClickListener](https://developer.android.com/reference/android/support/v7/preference/Preference.OnPreferenceClickListener)
  - [PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceDisplayDialogCallback)
  - [PreferenceFragmentCompat.OnPreferenceStartFragmentCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceStartFragmentCallback)
  - [PreferenceFragmentCompat.OnPreferenceStartScreenCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat.OnPreferenceStartScreenCallback)
  - [PreferenceGroup.PreferencePositionCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup.PreferencePositionCallback)
  - [PreferenceManager.OnDisplayPreferenceDialogListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnDisplayPreferenceDialogListener)
  - [PreferenceManager.OnNavigateToScreenListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnNavigateToScreenListener)
  - [PreferenceManager.OnPreferenceTreeClickListener](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.OnPreferenceTreeClickListener)
-

  ## Classes

  - [CheckBoxPreference](https://developer.android.com/reference/android/support/v7/preference/CheckBoxPreference)
  - [DialogPreference](https://developer.android.com/reference/android/support/v7/preference/DialogPreference)
  - [DropDownPreference](https://developer.android.com/reference/android/support/v7/preference/DropDownPreference)
  - [EditTextPreference](https://developer.android.com/reference/android/support/v7/preference/EditTextPreference)
  - [EditTextPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/EditTextPreferenceDialogFragmentCompat)
  - [ListPreference](https://developer.android.com/reference/android/support/v7/preference/ListPreference)
  - [ListPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/ListPreferenceDialogFragmentCompat)
  - [MultiSelectListPreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/MultiSelectListPreferenceDialogFragmentCompat)
  - [Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)
  - [Preference.BaseSavedState](https://developer.android.com/reference/android/support/v7/preference/Preference.BaseSavedState)
  - [PreferenceCategory](https://developer.android.com/reference/android/support/v7/preference/PreferenceCategory)
  - [PreferenceDataStore](https://developer.android.com/reference/android/support/v7/preference/PreferenceDataStore)
  - [PreferenceDialogFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceDialogFragmentCompat)
  - [PreferenceFragmentCompat](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat)
  - [PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup)
  - [PreferenceManager](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager)
  - [PreferenceManager.PreferenceComparisonCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.PreferenceComparisonCallback)
  - [PreferenceManager.SimplePreferenceComparisonCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceManager.SimplePreferenceComparisonCallback)
  - [PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)
  - [PreferenceViewHolder](https://developer.android.com/reference/android/support/v7/preference/PreferenceViewHolder)
  - [R](https://developer.android.com/reference/android/support/v7/preference/R)
  - [R.anim](https://developer.android.com/reference/android/support/v7/preference/R.anim)
  - [R.attr](https://developer.android.com/reference/android/support/v7/preference/R.attr)
  - [R.bool](https://developer.android.com/reference/android/support/v7/preference/R.bool)
  - [R.color](https://developer.android.com/reference/android/support/v7/preference/R.color)
  - [R.dimen](https://developer.android.com/reference/android/support/v7/preference/R.dimen)
  - [R.drawable](https://developer.android.com/reference/android/support/v7/preference/R.drawable)
  - [R.id](https://developer.android.com/reference/android/support/v7/preference/R.id)
  - [R.integer](https://developer.android.com/reference/android/support/v7/preference/R.integer)
  - [R.layout](https://developer.android.com/reference/android/support/v7/preference/R.layout)
  - [R.string](https://developer.android.com/reference/android/support/v7/preference/R.string)
  - [R.style](https://developer.android.com/reference/android/support/v7/preference/R.style)
  - [R.styleable](https://developer.android.com/reference/android/support/v7/preference/R.styleable)
  - [SeekBarPreference](https://developer.android.com/reference/android/support/v7/preference/SeekBarPreference)
  - [SwitchPreferenceCompat](https://developer.android.com/reference/android/support/v7/preference/SwitchPreferenceCompat)
  - [TwoStatePreference](https://developer.android.com/reference/android/support/v7/preference/TwoStatePreference)