android.preference
public
abstract
class
android.preference.PreferenceGroup
Summary
XML Attributes
Attribute name |
Related methods |
|
android:orderingFromXml |
|
Whether to order the Preference under this group as they appear in the XML file. |
android:defaultValue,
android:dependency,
android:enabled,
android:key,
android:layout,
android:order,
android:persistent,
android:selectable,
android:shouldDisableView,
android:summary,
android:title,
android:widgetLayout
Attribute name |
Related methods |
|
android:defaultValue |
|
The default value for the preference, which will be set either if persistence
is off or persistence is on and the preference is not found in the persistent
storage. |
android:dependency |
|
The key of another Preference that this Preference will depend on. |
android:enabled |
|
Whether the Preference is enabled. |
android:key |
|
The key to store the Preference value. |
android:layout |
|
The layout for the Preference in a PreferenceActivity screen. |
android:order |
|
The order for the Preference (lower values are to be ordered first). |
android:persistent |
|
Whether the Preference stores its value to the shared preferences. |
android:selectable |
|
Whether the Preference is selectable. |
android:shouldDisableView |
|
Whether the view of this Preference should be disabled when
this Preference is disabled. |
android:summary |
|
The summary for the Preference in a PreferenceActivity screen. |
android:title |
|
The title for the Preference in a PreferenceActivity screen. |
android:widgetLayout |
|
The layout for the controllable widget portion of a Preference. |
Public Constructors
Public Methods
Protected Methods
callChangeListener,
compareTo,
findPreferenceInHierarchy,
getContext,
getDependency,
getEditor,
getIntent,
getKey,
getLayoutResource,
getOnPreferenceChangeListener,
getOnPreferenceClickListener,
getOrder,
getPersistedBoolean,
getPersistedFloat,
getPersistedInt,
getPersistedLong,
getPersistedString,
getPreferenceManager,
getSharedPreferences,
getShouldDisableView,
getSummary,
getTitle,
getView,
getWidgetLayoutResource,
hasKey,
isEnabled,
isPersistent,
isSelectable,
notifyChanged,
notifyDependencyChange,
notifyHierarchyChanged,
onAttachedToActivity,
onAttachedToHierarchy,
onBindView,
onClick,
onCreateView,
onDependencyChanged,
onGetDefaultValue,
onPrepareForRemoval,
onRestoreInstanceState,
onSaveInstanceState,
onSetInitialValue,
persistBoolean,
persistFloat,
persistInt,
persistLong,
persistString,
restoreHierarchyState,
saveHierarchyState,
setDefaultValue,
setDependency,
setEnabled,
setIntent,
setKey,
setLayoutResource,
setOnPreferenceChangeListener,
setOnPreferenceClickListener,
setOrder,
setPersistent,
setSelectable,
setShouldDisableView,
setSummary,
setSummary,
setTitle,
setTitle,
setWidgetLayoutResource,
shouldCommit,
shouldDisableDependents,
shouldPersist,
toString
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
XML Attributes
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.
Must be a boolean value, either "true
" or "false
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol orderingFromXml.
Public Constructors
Public Methods
public
void
addItemFromInflater(Preference preference)
Called by the inflater to add an item to this group.
public
void
addItemFromInflater(T child)
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.
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. |
public
int
getPreferenceCount()
Returns the number of children
Preferences.
Returns
- The number of preference children in this group.
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.
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.
public
void
setEnabled(boolean enabled)
Sets whether this preference is enabled. If disabled, the preference will
not handle clicks.
Parameters
enabled
| Whether the preference is enabled.
|
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. |
Protected Methods
protected
void
dispatchRestoreInstanceState(Bundle container)
Called by
restoreHierarchyState(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.
Parameters
container
| The Bundle which holds previously frozen icicles. |
protected
void
dispatchSaveInstanceState(Bundle container)
Called by
saveHierarchyState(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.
Parameters
container
| The Bundle in which to save the preference's icicles. |
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.
protected
void
onAttachedToActivity()
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).
protected
void
onPrepareForRemoval()
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.