Build 1.0_r1(from source)

android.preference
Class PreferenceGroup

java.lang.Object
  extended by android.preference.Preference
      extended by android.preference.PreferenceGroup
All Implemented Interfaces:
GenericInflater.Parent<Preference>, OnDependencyChangeListener, Comparable<Preference>
Direct Known Subclasses:
PreferenceCategory, PreferenceScreen

public abstract class PreferenceGroup
extends Preference
implements GenericInflater.Parent<Preference>

The PreferenceGroup class is a container for multiple Preferences. It is a base class for Preference that are parents, such as PreferenceCategory and PreferenceScreen.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.preference.Preference
Preference.BaseSavedState, Preference.OnPreferenceChangeInternalListener, Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener
 
Field Summary
 
Fields inherited from class android.preference.Preference
DEFAULT_ORDER
 
Constructor Summary
PreferenceGroup(Context context, AttributeSet attrs)
           
PreferenceGroup(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 void addItemFromInflater(Preference preference)
          Called by the inflater to add an item to this group.
 boolean addPreference(Preference preference)
          Adds a Preference at the correct position based on the preference's order.
protected  void dispatchRestoreInstanceState(Bundle container)
          Called by Preference.restoreHierarchyState(android.os.Bundle) to retrieve the icicles for this preference and its children.
protected  void dispatchSaveInstanceState(Bundle container)
          Called by Preference.saveHierarchyState(android.os.Bundle) to store the icicles for this preference and its children.
 Preference findPreference(CharSequence key)
          Finds a Preference based on its key.
 Preference getPreference(int index)
          Returns the Preference at a particular index.
 int getPreferenceCount()
          Returns the number of children Preferences.
protected  boolean isOnSameScreenAsChildren()
          Whether this preference group should be shown on the same screen as its contained preferences.
 boolean isOrderingAsAdded()
          Whether this group is ordering preferences in the order they are added.
protected  void onAttachedToActivity()
          Called when the preference hierarchy has been attached to the PreferenceActivity.
protected  boolean onPrepareAddPreference(Preference preference)
          Prepares a Preference to be added to the group.
protected  void onPrepareForRemoval()
          Called when this Preference is being removed from the hierarchy.
 void removeAll()
          Removes all Preferences from this group.
 boolean removePreference(Preference preference)
          Removes a Preference from this group.
 void setEnabled(boolean enabled)
          Sets whether this preference is enabled.
 void setOrderingAsAdded(boolean orderingAsAdded)
          Whether to order the Preference children of this group as they are added.
(package private)  void sortPreferences()
           
 
Methods inherited from class android.preference.Preference
callChangeListener, compareTo, findPreferenceInHierarchy, getContext, getDependency, getEditor, getFilterableStringBuilder, getId, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPreferenceManager, getSharedPreferences, getShouldDisableView, getSummary, getTitle, getView, getWidgetLayoutResource, hasKey, hasSpecifiedLayout, isEnabled, isPersistent, isSelectable, notifyChanged, notifyDependencyChange, notifyHierarchyChanged, onAttachedToHierarchy, onBindView, onClick, onCreateView, onDependencyChanged, onGetDefaultValue, onRestoreInstanceState, onSaveInstanceState, onSetInitialValue, performClick, persistBoolean, persistFloat, persistInt, persistLong, persistString, requireKey, restoreHierarchyState, saveHierarchyState, setDefaultValue, setDependency, setIntent, setKey, setLayoutResource, setOnPreferenceChangeInternalListener, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setSelectable, setShouldDisableView, setSummary, setSummary, setTitle, setTitle, setWidgetLayoutResource, shouldCommit, shouldDisableDependents, shouldPersist, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PreferenceGroup

public PreferenceGroup(Context context,
                       AttributeSet attrs,
                       int defStyle)

PreferenceGroup

public PreferenceGroup(Context context,
                       AttributeSet attrs)
Method Detail

setOrderingAsAdded

public void setOrderingAsAdded(boolean orderingAsAdded)
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 - Whether to order according to the order added.
See Also:
Preference.setOrder(int)

isOrderingAsAdded

public boolean isOrderingAsAdded()
Whether this group is ordering preferences in the order they are added.

Returns:
Whether this group orders based on the order the children are added.
See Also:
setOrderingAsAdded(boolean)

addItemFromInflater

public void addItemFromInflater(Preference preference)
Called by the inflater to add an item to this group.

Specified by:
addItemFromInflater in interface GenericInflater.Parent<Preference>

getPreferenceCount

public int getPreferenceCount()
Returns the number of children Preferences.

Returns:
The number of preference children in this group.

getPreference

public Preference getPreference(int index)
Returns the Preference at a particular index.

Parameters:
index - The index of the Preference to retrieve.
Returns:
The Preference.

addPreference

public boolean addPreference(Preference preference)
Adds a Preference at the correct position based on the preference's order.

Parameters:
preference - The preference to add.
Returns:
Whether the preference is now in this group.

removePreference

public boolean removePreference(Preference preference)
Removes a Preference from this group.

Parameters:
preference - The preference to remove.
Returns:
Whether the preference was found and removed.

removeAll

public void removeAll()
Removes all Preferences from this group.


onPrepareAddPreference

protected boolean onPrepareAddPreference(Preference preference)
Prepares a Preference to be added to the group.

Parameters:
preference - The preference to add.
Returns:
Whether to allow adding the preference (true), or not (false).

findPreference

public Preference findPreference(CharSequence key)
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 - The key of the preference to retrieve.
Returns:
The Preference with the key, or null.

isOnSameScreenAsChildren

protected boolean isOnSameScreenAsChildren()
Whether this preference group should be shown on the same screen as its contained preferences.

Returns:
True if the contained preferences should be shown on the same screen as this preference.

onAttachedToActivity

protected void onAttachedToActivity()
Description copied from class: Preference
Called when the preference hierarchy has been attached to the PreferenceActivity. This can also be called when this Preference has been attached to a group that was already attached to the PreferenceActivity.

Overrides:
onAttachedToActivity in class Preference

onPrepareForRemoval

protected void onPrepareForRemoval()
Description copied from class: Preference
Called when this Preference is being removed from the hierarchy. You should remove any references to this Preference that you know about. Make sure to call through to the superclass implementation.

Overrides:
onPrepareForRemoval in class Preference

setEnabled

public void setEnabled(boolean enabled)
Description copied from class: Preference
Sets whether this preference is enabled. If disabled, the preference will not handle clicks.

Overrides:
setEnabled in class Preference
Parameters:
enabled - Whether the preference is enabled.

sortPreferences

void sortPreferences()

dispatchSaveInstanceState

protected void dispatchSaveInstanceState(Bundle container)
Description copied from class: Preference
Called by Preference.saveHierarchyState(android.os.Bundle) to store the icicles for this preference and its children. May be overridden to modify how freezing happens to a preference's children; for example, some preferences may want to not store icicles for their children.

Overrides:
dispatchSaveInstanceState in class Preference
Parameters:
container - The Bundle in which to save the preference's icicles.
See Also:
Preference.dispatchRestoreInstanceState(android.os.Bundle), Preference.saveHierarchyState(android.os.Bundle), Preference.onSaveInstanceState()

dispatchRestoreInstanceState

protected void dispatchRestoreInstanceState(Bundle container)
Description copied from class: Preference
Called by Preference.restoreHierarchyState(android.os.Bundle) to retrieve the icicles for this preference and its children. May be overridden to modify how restoreing happens to a preference's children; for example, some preferences may want to not store icicles for their children.

Overrides:
dispatchRestoreInstanceState in class Preference
Parameters:
container - The Bundle which holds previously frozen icicles.
See Also:
Preference.dispatchSaveInstanceState(android.os.Bundle), Preference.restoreHierarchyState(android.os.Bundle), Preference.onRestoreInstanceState(android.os.Parcelable)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature