# PreferenceGroup

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:[Nested Classes](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#nestedclasses)\|[XML Attrs](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#lattrs)\|[Inherited XML Attrs](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#inhattrs)\|[Inherited Constants](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#inhconstants)\|[Ctors](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#)  

# PreferenceGroup

| 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


abstract
class
PreferenceGroup
`  
`


``

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


``


`

|---|---|-----------------------------------------------|
| 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/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#)Known Direct Subclasses [PreferenceCategory](https://developer.android.com/reference/android/support/v7/preference/PreferenceCategory),[PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen) |----------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [PreferenceCategory](https://developer.android.com/reference/android/support/v7/preference/PreferenceCategory) | Used to group[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)objects and provide a disabled title above the group. | | [PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen)     | Represents a top-level[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)that is the root of a Preference hierarchy.  | |

<br />

*** ** * ** ***

A container for multiple[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)objects. It is a base class for Preference objects that are parents, such as[PreferenceCategory](https://developer.android.com/reference/android/support/v7/preference/PreferenceCategory)and[PreferenceScreen](https://developer.android.com/reference/android/support/v7/preference/PreferenceScreen).  

### Developer Guides

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

<br />

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ### Nested classes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ||
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [PreferenceGroup.PreferencePositionCallback](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup.PreferencePositionCallback) Interface for PreferenceGroup Adapters to implement so that[scrollToPreference(String)](https://developer.android.com/reference/android/support/v14/preference/PreferenceFragment#scrollToPreference(java.lang.String))and[scrollToPreference(Preference)](https://developer.android.com/reference/android/support/v14/preference/PreferenceFragment#scrollToPreference(android.support.v7.preference.Preference))or[scrollToPreference(String)](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat#scrollToPreference(java.lang.String))and[scrollToPreference(Preference)](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat#scrollToPreference(android.support.v7.preference.Preference))can determine the correct scroll position to request. |

|                                                                                      ### XML attributes                                                                                      ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [`PreferenceGroup_initialExpandedChildrenCount`](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#attr_PreferenceGroup_initialExpandedChildrenCount) |   |

| ### Inherited XML attributes |
|------------------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#)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/PreferenceGroup#)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 constructors                                                                                                                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#PreferenceGroup(android.content.Context, android.util.AttributeSet, int, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs, int defStyleAttr, int defStyleRes) ` |
| ` `[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#PreferenceGroup(android.content.Context, android.util.AttributeSet, int))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs, int defStyleAttr) `                       |
| ` `[PreferenceGroup](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#PreferenceGroup(android.content.Context, android.util.AttributeSet))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context, `[AttributeSet](https://developer.android.com/reference/android/util/AttributeSet.html)` attrs) `                                              |

|                                                                                                                                                                                                                                                                ### Public methods                                                                                                                                                                                                                                                                 ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` 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. |
| ` `[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`                                                                                        | ` `[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.                                                                                                                                                                                                                                  |
| ` 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.                                                                                                             |

|                                                                                                                                                                                                                                                                                         ### Protected methods                                                                                                                                                                                                                                                                                          ||
|-------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` 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.                              |
| ` 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`                                                                          | ` `[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.                                                                                                                                                                                                                    |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#)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/PreferenceGroup#)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/PreferenceGroup#)From interface` java.lang.Comparable ` |-----------------|----------------------------------------------------------------------------------------------------------------------| | ` abstract int` | ` compareTo(`[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)` arg0) ` | ||

## XML attributes

### PreferenceGroup_initialExpandedChildrenCount

<br />

<br />

**Related methods:**

- [setInitialExpandedChildrenCount(int)](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#setInitialExpandedChildrenCount(int))

## Public constructors

### PreferenceGroup

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

```
PreferenceGroup (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)
```

<br />

<br />

|              Parameters               ||
|----------------|-----------------------|
| `context`      | `Context` <br />      |
| `attrs`        | `AttributeSet` <br /> |
| `defStyleAttr` | `int` <br />          |
| `defStyleRes`  | `int` <br />          |

### PreferenceGroup

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

```
PreferenceGroup (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)
```

<br />

<br />

|              Parameters               ||
|----------------|-----------------------|
| `context`      | `Context` <br />      |
| `attrs`        | `AttributeSet` <br /> |
| `defStyleAttr` | `int` <br />          |

### PreferenceGroup

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

```
PreferenceGroup (Context context, 
                AttributeSet attrs)
```

<br />

<br />

|            Parameters            ||
|-----------|-----------------------|
| `context` | `Context` <br />      |
| `attrs`   | `AttributeSet` <br /> |

## Public methods

### addItemFromInflater

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

```
void addItemFromInflater (Preference preference)
```

Called by the inflater to add an item to this group.

<br />

|            Parameters             ||
|--------------|---------------------|
| `preference` | `Preference` <br /> |

### addPreference

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

```
boolean addPreference (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.

<br />

|                        Parameters                         ||
|--------------|---------------------------------------------|
| `preference` | `Preference`: The preference to add. <br /> |

|                            Returns                             ||
|-----------|-----------------------------------------------------|
| `boolean` | Whether the preference is now in this group. <br /> |

### findPreference

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

```
Preference findPreference (CharSequence key)
```

Finds a[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)based on its key. If two[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)share the same key (not recommended), the first to appear will be returned (to retrieve the other preference with the same key, call this method on the first preference). If this preference has the key, it will not be returned.

This will recursively search for the preference into children that are also[PreferenceGroups](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup).

<br />

|                              Parameters                              ||
|-------|---------------------------------------------------------------|
| `key` | `CharSequence`: The key of the preference to retrieve. <br /> |

|                                                                                                            Returns                                                                                                             ||
|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| [Preference](https://developer.android.com/reference/android/support/v7/preference/Preference) | The[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)with the key, or null. <br /> |

### getInitialExpandedChildrenCount

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

```
int getInitialExpandedChildrenCount ()
```

Gets the maximal number of children that is initially shown.

<br />

**Related XML Attributes:**

- [PreferenceGroup_initialExpandedChildrenCount](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#attr_PreferenceGroup_initialExpandedChildrenCount)

|                                Returns                                ||
|-------|----------------------------------------------------------------|
| `int` | the maximal number of children that is initially shown. <br /> |

### getPreference

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

```
Preference getPreference (int index)
```

Returns the[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)at a particular index.

<br />

|                                                                    Parameters                                                                     ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------|
| `index` | `int`: The index of the[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)to retrieve. <br /> |

|                                                                                                  Returns                                                                                                  ||
|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| [Preference](https://developer.android.com/reference/android/support/v7/preference/Preference) | The[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference). <br /> |

### getPreferenceCount

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

```
int getPreferenceCount ()
```

Returns the number of children[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)s.

<br />

|                            Returns                             ||
|-------|---------------------------------------------------------|
| `int` | The number of preference children in this group. <br /> |

### isOrderingAsAdded

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

```
boolean isOrderingAsAdded ()
```

Whether this group is ordering preferences in the order they are added.

<br />

|                                        Returns                                         ||
|-----------|-----------------------------------------------------------------------------|
| `boolean` | Whether this group orders based on the order the children are added. <br /> |

**See also:**

- [setOrderingAsAdded(boolean)](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#setOrderingAsAdded(boolean))  

### notifyDependencyChange

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

```
void notifyDependencyChange (boolean disableDependents)
```

Notifies any listening dependents of a change that affects the dependency.

<br />

|                                          Parameters                                           ||
|---------------------|--------------------------------------------------------------------------|
| `disableDependents` | `boolean`: Whether this Preference should disable its dependents. <br /> |

### onAttached

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

```
void onAttached ()
```

Called when the Preference hierarchy has been attached to the list of preferences. This can also be called when this Preference has been attached to a group that was already attached to the list of preferences.

<br />

### onDetached

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

```
void onDetached ()
```

Called when the Preference hierarchy has been detached from the list of preferences. This can also be called when this Preference has been removed from a group that was attached to the list of preferences.

<br />

### removeAll

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

```
void removeAll ()
```

Removes all[Preferences](https://developer.android.com/reference/android/support/v7/preference/Preference)from this group.

<br />

### removePreference

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

```
boolean removePreference (Preference preference)
```

Removes a[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)from this group.

<br />

|                          Parameters                          ||
|--------------|------------------------------------------------|
| `preference` | `Preference`: The preference to remove. <br /> |

|                             Returns                             ||
|-----------|------------------------------------------------------|
| `boolean` | Whether the preference was found and removed. <br /> |

### setInitialExpandedChildrenCount

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

```
void setInitialExpandedChildrenCount (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. If some children are hidden an expand button will be provided to show all the hidden children. Any child in any level of the hierarchy that is also a preference group (e.g. preference category) will not be counted towards the limit. But instead the children of such group will be counted. By default, all children will be shown, so the default value of this attribute is equal to Integer.MAX_VALUE.

<br />

**Related XML Attributes:**

- [PreferenceGroup_initialExpandedChildrenCount](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#attr_PreferenceGroup_initialExpandedChildrenCount)

|                                   Parameters                                   ||
|-----------------|---------------------------------------------------------------|
| `expandedCount` | `int`: the number of children that is initially shown. <br /> |

### setOrderingAsAdded

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

```
void setOrderingAsAdded (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. If this is false, the ordering will follow each Preference order and default to alphabetic for those without an order.

If this is called after preferences are added, they will not be re-ordered in the order they were added, hence call this method early on.

<br />

|                                     Parameters                                      ||
|-------------------|------------------------------------------------------------------|
| `orderingAsAdded` | `boolean`: Whether to order according to the order added. <br /> |

**See also:**

- [setOrder(int)](https://developer.android.com/reference/android/support/v7/preference/Preference#setOrder(int))

## Protected methods

### dispatchRestoreInstanceState

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

```
void dispatchRestoreInstanceState (Bundle 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. May be overridden to modify how restoring happens to the children of a Preference. For example, some Preference objects may not want to save state for their children.

<br />

|                                   Parameters                                    ||
|-------------|--------------------------------------------------------------------|
| `container` | `Bundle`: The Bundle that holds the previously saved state. <br /> |

### dispatchSaveInstanceState

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

```
void dispatchSaveInstanceState (Bundle 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. May be overridden to modify how the save happens for children. For example, some Preference objects may want to not store an instance for their children.

<br />

|                                         Parameters                                         ||
|-------------|-------------------------------------------------------------------------------|
| `container` | `Bundle`: The Bundle in which to save the instance of this Preference. <br /> |

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

### onPrepareAddPreference

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

```
boolean onPrepareAddPreference (Preference preference)
```

Prepares a[Preference](https://developer.android.com/reference/android/support/v7/preference/Preference)to be added to the group.

<br />

|                        Parameters                         ||
|--------------|---------------------------------------------|
| `preference` | `Preference`: The preference to add. <br /> |

|                                     Returns                                      ||
|-----------|-----------------------------------------------------------------------|
| `boolean` | Whether to allow adding the preference (true), or not (false). <br /> |

### onRestoreInstanceState

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

```
void onRestoreInstanceState (Parcelable 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()). This function will never be called with a null state.

<br />

|                                                                                                       Parameters                                                                                                        ||
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `state` | `Parcelable`: The saved state that had previously been returned by[onSaveInstanceState()](https://developer.android.com/reference/android/support/v7/preference/PreferenceGroup#onSaveInstanceState()). <br /> |

### onSaveInstanceState

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

```
Parcelable onSaveInstanceState ()
```

Hook allowing a Preference to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can be reconstructed later.

<br />

|                                                                                                                             Returns                                                                                                                             ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Parcelable](https://developer.android.com/reference/android/os/Parcelable.html) | A Parcelable object containing the current dynamic state of this Preference, or null if there is nothing interesting to save. The default implementation returns null. <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)