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
PreferenceGroup(context: Context!, attrs: AttributeSet!)

PreferenceGroup(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

PreferenceGroup(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

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

PreferenceGroup

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

PreferenceGroup

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

PreferenceGroup

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

Public methods

addItemFromInflater

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

Deprecated: Deprecated in Java.

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

addPreference

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

Deprecated: Deprecated in Java.

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
open fun findPreference(key: CharSequence!): Preference!

Deprecated: Deprecated in Java.

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 PreferenceGroups.

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
open fun getPreference(index: Int): Preference!

Deprecated: Deprecated in Java.

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
open fun getPreferenceCount(): Int

Deprecated: Deprecated in Java.

Returns the number of children Preferences.

Return
Int The number of preference children in this group.

isOrderingAsAdded

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

Deprecated: Deprecated in Java.

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
open fun notifyDependencyChange(disableDependents: Boolean): Unit

Deprecated: Deprecated in Java.

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

removeAll

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

Deprecated: Deprecated in Java.

Removes all Preferences from this group.

removePreference

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

Deprecated: Deprecated in Java.

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
open fun setOrderingAsAdded(orderingAsAdded: Boolean): Unit

Deprecated: Deprecated in Java.

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
protected open fun dispatchRestoreInstanceState(container: Bundle!): Unit

Deprecated: Deprecated in Java.

dispatchSaveInstanceState

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

Deprecated: Deprecated in Java.

isOnSameScreenAsChildren

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

Deprecated: Deprecated in Java.

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
protected open fun onAttachedToActivity(): Unit

Deprecated: Deprecated in Java.

onPrepareAddPreference

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

Deprecated: Deprecated in Java.

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
protected open fun onPrepareForRemoval(): Unit

Deprecated: Deprecated in Java.