Google is committed to advancing racial equity for Black communities. See how.
Added in API level 1
Deprecated in API level 29

PreferenceGroup

abstract class PreferenceGroup : Preference
kotlin.Any
   ↳ android.preference.Preference
   ↳ android.preference.PreferenceGroup

A container for multiple Preference objects. It is a base class for Preference objects that are parents, such as PreferenceCategory and PreferenceScreen.

Summary

XML attributes

android:orderingFromXml Whether to order the Preference under this group as they appear in the XML file.

Inherited XML attributes

Inherited constants

Public constructors

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

<init>(context: Context!, attrs: AttributeSet!)

Public methods

open Unit

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

open Boolean
addPreference(preference: Preference!)

Adds a Preference at the correct position based on the preference's order.

open Preference!

Finds a Preference based on its key.

open Preference!

Returns the Preference at a particular index.

open Int

Returns the number of children Preferences.

open Boolean

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

open Unit
notifyDependencyChange(disableDependents: Boolean)

open Unit

Removes all Preference from this group.

open Boolean

Removes a Preference from this group.

open Unit
setOrderingAsAdded(orderingAsAdded: Boolean)

Whether to order the Preference children of this group as they are added.

Protected methods

open Unit

open Unit

open Boolean

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

open Unit

open Boolean

Prepares a Preference to be added to the group.

open Unit

Inherited functions

XML attributes

android:orderingFromXml

android:orderingFromXml
Whether to order the Preference under this group as they appear in the XML file. If this is false, the ordering will follow the Preference order attribute and default to alphabetic for those without the order attribute.

May be a boolean value, such as "true" or "false".

Public constructors

<init>

Added in API level 21
PreferenceGroup(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

<init>

Added in API level 1
PreferenceGroup(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

<init>

Added in API level 1
PreferenceGroup(
    context: Context!,
    attrs: AttributeSet!)

Public methods

addItemFromInflater

Added in API level 1
Deprecated in API level 29
open fun addItemFromInflater(preference: Preference!): Unit

Deprecated.

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

addPreference

Added in API level 1
Deprecated in API level 29
open fun addPreference(preference: Preference!): Boolean

Deprecated.

Adds a Preference at the correct position based on the preference's order.

Parameters
preference Preference!: The preference to add.
Return
Boolean Whether the preference is now in this group.

findPreference

Added in API level 1
Deprecated in API level 29
open fun findPreference(key: CharSequence!): Preference!

Deprecated.

Finds a Preference based on its key. If two 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 PreferenceGroup.

Parameters
key CharSequence!: The key of the preference to retrieve.
Return
Preference! The Preference with the key, or null.

getPreference

Added in API level 1
Deprecated in API level 29
open fun getPreference(index: Int): Preference!

Deprecated.

Returns the Preference at a particular index.

Parameters
index Int: The index of the Preference to retrieve.
Return
Preference! The Preference.

getPreferenceCount

Added in API level 1
Deprecated in API level 29
open fun getPreferenceCount(): Int

Deprecated.

Returns the number of children Preferences.

Return
Int The number of preference children in this group.

isOrderingAsAdded

Added in API level 1
Deprecated in API level 29
open fun isOrderingAsAdded(): Boolean

Deprecated.

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

Return
Boolean Whether this group orders based on the order the children are added.

notifyDependencyChange

Added in API level 1
Deprecated in API level 29
open fun notifyDependencyChange(disableDependents: Boolean): Unit

Deprecated.

Parameters
disableDependents Boolean: Whether this Preference should disable its dependents.

removeAll

Added in API level 1
Deprecated in API level 29
open fun removeAll(): Unit

Deprecated.

Removes all Preference from this group.

removePreference

Added in API level 1
Deprecated in API level 29
open fun removePreference(preference: Preference!): Boolean

Deprecated.

Removes a Preference from this group.

Parameters
preference Preference!: The preference to remove.
Return
Boolean Whether the preference was found and removed.

setOrderingAsAdded

Added in API level 1
Deprecated in API level 29
open fun setOrderingAsAdded(orderingAsAdded: Boolean): Unit

Deprecated.

Whether to order the 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.

Parameters
orderingAsAdded Boolean: Whether to order according to the order added.

Protected methods

dispatchRestoreInstanceState

Added in API level 1
Deprecated in API level 29
protected open fun dispatchRestoreInstanceState(container: Bundle!): Unit

Deprecated.

dispatchSaveInstanceState

Added in API level 1
Deprecated in API level 29
protected open fun dispatchSaveInstanceState(container: Bundle!): Unit

Deprecated.

isOnSameScreenAsChildren

Added in API level 1
Deprecated in API level 29
protected open fun isOnSameScreenAsChildren(): Boolean

Deprecated.

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

Return
Boolean True if the contained preferences should be shown on the same screen as this preference.

onAttachedToActivity

Added in API level 1
Deprecated in API level 29
protected open fun onAttachedToActivity(): Unit

Deprecated.

onPrepareAddPreference

Added in API level 1
Deprecated in API level 29
protected open fun onPrepareAddPreference(preference: Preference!): Boolean

Deprecated.

Prepares a Preference to be added to the group.

Parameters
preference Preference!: The preference to add.
Return
Boolean Whether to allow adding the preference (true), or not (false).

onPrepareForRemoval

Added in API level 1
Deprecated in API level 29
protected open fun onPrepareForRemoval(): Unit

Deprecated.