java.lang.Object | |||
↳ | android.preference.Preference | ||
↳ | android.preference.PreferenceGroup | ||
↳ | android.preference.PreferenceScreen |
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 createPreferenceScreen(Context).
Here's an example XML layout of a PreferenceScreen:
<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).
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.preference.PreferenceGroup
| |||||||||||
From class
android.preference.Preference
|
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.preference.Preference
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Used to get a handle to the dialog.
| |||||||||||
Returns an adapter that can be attached to a PreferenceActivity
to show the preferences contained in this PreferenceScreen.
| |||||||||||
This method will be invoked when the dialog is dismissed.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Whether this preference group should be shown on the same screen as its
contained preferences.
| |||||||||||
Processes a click on the preference.
| |||||||||||
Creates the root adapter.
| |||||||||||
Hook allowing a Preference to re-apply a representation of its internal
state that had previously been generated by 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.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class android.preference.PreferenceGroup
| |||||||||||
From class android.preference.Preference
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface android.content.DialogInterface.OnDismissListener
| |||||||||||
From interface android.widget.AdapterView.OnItemClickListener
| |||||||||||
From interface java.lang.Comparable
|
Binds a 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. |
---|
Used to get a handle to the dialog. This is useful for cases where we want to manipulate the dialog as we would with any other activity or view.
Returns an adapter that can be attached to a 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 getItem(int) should always return a subclass of Preference.
This method will be invoked when the dialog is dismissed.
dialog | The dialog that was dismissed will be passed into the method. |
---|
Whether this preference group should be shown on the same screen as its contained preferences.
Processes a click on the preference. This includes saving the value to the SharedPreferences. However, the overridden method should call callChangeListener(Object) to make sure the client wants to update the preference's state with the new value.
Creates the root adapter.
Hook allowing a Preference to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState(). This function will never be called with a null state.
state | The saved state that had previously been returned by 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. This state should only contain information that is not persistent or can be reconstructed later.