|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.preference.Preference
android.preference.PreferenceGroup
android.preference.PreferenceScreen
public final class PreferenceScreen
The PreferenceScreen class represents a top-level Preference that
is the root of a Preference hierarchy. A PreferenceActivity
points to an instance of this class to show the preferences. To instantiate
this class, use PreferenceManager.createPreferenceScreen(Context).
This class can appear in two places:
PreferenceActivity points to this, it is used as the root
and is not shown (only the contained preferences are shown).
Dialog or via a
Context.startActivity(android.content.Intent) from the
Preference.getIntent()). The children of this PreferenceScreen
are NOT shown in the screen that this PreferenceScreen is shown in.
Instead, a separate screen will be shown when this preference is clicked.
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="first_preferencescreen">
<CheckBoxPreference
android:key="wifi enabled"
android:title="WiFi" />
<PreferenceScreen
android:key="second_preferencescreen"
android:title="WiFi settings">
<CheckBoxPreference
android:key="prefer wifi"
android:title="Prefer WiFi" />
... other preferences here ...
</PreferenceScreen>
</PreferenceScreen>
In this example, the "first_preferencescreen" will be used as the root of the
hierarchy and given to a PreferenceActivity. The first screen will
show preferences "WiFi" (which can be used to quickly enable/disable WiFi)
and "WiFi settings". The "WiFi settings" is the "second_preferencescreen" and when
clicked will show another screen of preferences such as "Prefer WiFi" (and
the other preferences that are children of the "second_preferencescreen" tag).
PreferenceCategory| 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 | |
|---|---|
PreferenceScreen(Context context,
AttributeSet attrs)
Do NOT use this constructor, use PreferenceManager.createPreferenceScreen(Context). |
|
| Method Summary | |
|---|---|
void |
bind(ListView listView)
Binds a ListView to the preferences contained in this PreferenceScreen via
getRootAdapter(). |
Dialog |
getDialog()
Used to get a handle to the dialog. |
ListAdapter |
getRootAdapter()
Returns an adapter that can be attached to a PreferenceActivity
to show the preferences contained in this PreferenceScreen. |
protected boolean |
isOnSameScreenAsChildren()
Whether this preference group should be shown on the same screen as its contained preferences. |
protected void |
onClick()
Processes a click on the preference. |
protected ListAdapter |
onCreateRootAdapter()
Creates the root adapter. |
void |
onDismiss(DialogInterface dialog)
This method will be invoked when the dialog is dismissed. |
void |
onItemClick(AdapterView parent,
View view,
int position,
long id)
Callback method to be invoked when an item in this AdapterView has been clicked. |
protected void |
onRestoreInstanceState(Parcelable state)
Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by Preference.onSaveInstanceState(). |
protected 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. |
| Methods inherited from class android.preference.PreferenceGroup |
|---|
addItemFromInflater, addPreference, dispatchRestoreInstanceState, dispatchSaveInstanceState, findPreference, getPreference, getPreferenceCount, isOrderingAsAdded, onAttachedToActivity, onPrepareAddPreference, onPrepareForRemoval, removeAll, removePreference, setEnabled, setOrderingAsAdded, sortPreferences |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PreferenceScreen(Context context, AttributeSet attrs)
PreferenceManager.createPreferenceScreen(Context).
| Method Detail |
|---|
public ListAdapter getRootAdapter()
PreferenceActivity
to show the preferences contained in this PreferenceScreen.
This PreferenceScreen will NOT appear in the returned adapter, instead
it appears in the hierarchy above this PreferenceScreen.
This adapter's Adapter.getItem(int) should always return a
subclass of Preference.
Preference contained in this
PreferenceScreen.PreferenceGroupAdapterprotected ListAdapter onCreateRootAdapter()
PreferenceScreen.getRootAdapter()public void bind(ListView listView)
ListView to the preferences contained in this PreferenceScreen via
getRootAdapter(). It also handles passing list item clicks to the corresponding
Preference contained by this PreferenceScreen.
listView - The list view to attach to.protected void onClick()
PreferenceSharedPreferences. However, the overridden method should
call Preference.callChangeListener(Object) to make sure the client wants to
update the preference's state with the new value.
onClick in class Preferencepublic void onDismiss(DialogInterface dialog)
DialogInterface.OnDismissListener
onDismiss in interface DialogInterface.OnDismissListenerdialog - The dialog that was dismissed will be passed into the
method.public Dialog getDialog()
public void onItemClick(AdapterView parent, View view, int position, long id)
AdapterView.OnItemClickListenerImplementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.
onItemClick in interface AdapterView.OnItemClickListenerparent - The AdapterView where the click happened.view - The view within the AdapterView that was clicked (this
will be a view provided by the adapter)position - The position of the view in the adapter.id - The row id of the item that was clicked.protected boolean isOnSameScreenAsChildren()
PreferenceGroup
isOnSameScreenAsChildren in class PreferenceGroupprotected Parcelable onSaveInstanceState()
Preference
onSaveInstanceState in class PreferencePreference.onRestoreInstanceState(android.os.Parcelable),
Preference.saveHierarchyState(android.os.Bundle),
Preference.dispatchSaveInstanceState(android.os.Bundle)protected void onRestoreInstanceState(Parcelable state)
PreferencePreference.onSaveInstanceState().
This function will never be called with a null icicle.
onRestoreInstanceState in class Preferencestate - The frozen state that had previously been returned by
Preference.onSaveInstanceState().Preference.onSaveInstanceState(),
Preference.restoreHierarchyState(android.os.Bundle),
Preference.dispatchRestoreInstanceState(android.os.Bundle)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||