java.lang.Object | ||
↳ | android.preference.Preference | |
↳ | android.preference.DialogPreference |
Known Direct Subclasses |
A base class for Preference
objects that are
dialog-based. These preferences will, when clicked, open a dialog showing the
actual preference controls.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
android:dialogIcon | The icon for the dialog. | ||||||||||
android:dialogLayout | A layout to be used as the content View for the dialog. | ||||||||||
android:dialogMessage | The message in the dialog. | ||||||||||
android:dialogTitle | The title in the dialog. | ||||||||||
android:negativeButtonText | The negative button text for the dialog. | ||||||||||
android:positiveButtonText | The positive button text for the dialog. |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.preference.Preference
|
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.preference.Preference
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the dialog that is shown by this preference.
| |||||||||||
Returns the icon to be shown on subsequent dialogs.
| |||||||||||
Returns the layout resource that is used as the content View for
subsequent dialogs.
| |||||||||||
Returns the message to be shown on subsequent dialogs.
| |||||||||||
Returns the title to be shown on subsequent dialogs.
| |||||||||||
Returns the text of the negative button to be shown on subsequent
dialogs.
| |||||||||||
Returns the text of the positive button to be shown on subsequent
dialogs.
| |||||||||||
See Activity's onDestroy.
| |||||||||||
This method will be invoked when a button in the dialog is clicked.
| |||||||||||
This method will be invoked when the dialog is dismissed.
| |||||||||||
Sets the icon (resource ID) of the dialog.
| |||||||||||
Sets the icon of the dialog.
| |||||||||||
Sets the layout resource that is inflated as the
View to be shown
as the content View of subsequent dialogs. | |||||||||||
Sets the message of the dialog.
| |||||||||||
Sets the title of the dialog.
| |||||||||||
Sets the text of the negative button of the dialog.
| |||||||||||
Sets the text of the positive button of the dialog.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Binds views in the content View of the dialog to data.
| |||||||||||
Processes a click on the preference.
| |||||||||||
Creates the content view for the dialog (if a custom content view is
required).
| |||||||||||
Called when the dialog is dismissed and should be used to save data to
the
SharedPreferences . | |||||||||||
Prepares the dialog builder to be shown when the preference is clicked.
| |||||||||||
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.
| |||||||||||
Shows the dialog associated with this Preference.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.preference.Preference
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.content.DialogInterface.OnClickListener
| |||||||||||
From interface
android.content.DialogInterface.OnDismissListener
| |||||||||||
From interface
android.preference.PreferenceManager.OnActivityDestroyListener
| |||||||||||
From interface
java.lang.Comparable
|
The icon for the dialog.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute
resource symbol dialogIcon
.
A layout to be used as the content View for the dialog. By default, this shouldn't be needed. If a custom DialogPreference is required, this should be set. For example, the EditTextPreference uses a layout with an EditText as this attribute.
Must be a reference to another resource, in the form "@[+][package:]type:name
"
or to a theme attribute in the form "?[package:][type:]name
".
This corresponds to the global attribute
resource symbol dialogLayout
.
The message in the dialog. If a dialogLayout is provided and contains a TextView with ID android:id/message, this message will be placed in there.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
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 dialogMessage
.
The title in the dialog.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
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 dialogTitle
.
The negative button text for the dialog. Set to @null to hide the negative button.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
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 negativeButtonText
.
The positive button text for the dialog. Set to @null to hide the positive button.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
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 positiveButtonText
.
Gets the dialog that is shown by this preference.
Returns the icon to be shown on subsequent dialogs.
Drawable
.
Returns the layout resource that is used as the content View for subsequent dialogs.
Returns the message to be shown on subsequent dialogs.
Returns the title to be shown on subsequent dialogs.
Returns the text of the negative button to be shown on subsequent dialogs.
Returns the text of the positive button to be shown on subsequent dialogs.
This method will be invoked when a button in the dialog is clicked.
dialog | The dialog that received the click. |
---|---|
which | The button that was clicked (e.g.
BUTTON1 ) or the position
of the item clicked.
|
This method will be invoked when the dialog is dismissed.
dialog | The dialog that was dismissed will be passed into the method. |
---|
Sets the icon (resource ID) of the dialog. This will be shown on subsequent dialogs.
dialogIconRes | The icon, as a resource ID. |
---|
Sets the icon of the dialog. This will be shown on subsequent dialogs.
dialogIcon | The icon, as a Drawable .
|
---|
Sets the layout resource that is inflated as the View
to be shown
as the content View of subsequent dialogs.
dialogLayoutResId | The layout resource ID to be inflated. |
---|
Sets the message of the dialog. This will be shown on subsequent dialogs.
This message forms the content View of the dialog and conflicts with
list-based dialogs, for example. If setting a custom View on a dialog via
setDialogLayoutResource(int)
, include a text View with ID
message
and it will be populated with this message.
dialogMessage | The message. |
---|
dialogMessageResId | The dialog message as a resource. |
---|
Sets the title of the dialog. This will be shown on subsequent dialogs.
dialogTitle | The title. |
---|
negativeButtonTextResId | The negative button text as a resource. |
---|
Sets the text of the negative button of the dialog. This will be shown on subsequent dialogs.
negativeButtonText | The text of the negative button. |
---|
positiveButtonTextResId | The positive button text as a resource. |
---|
Sets the text of the positive button of the dialog. This will be shown on subsequent dialogs.
positiveButtonText | The text of the positive button. |
---|
Binds views in the content View of the dialog to data.
Make sure to call through to the superclass implementation.
view | The content View of the dialog, if it is custom. |
---|
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 content view for the dialog (if a custom content view is required). By default, it inflates the dialog layout resource if it is set.
Called when the dialog is dismissed and should be used to save data to
the SharedPreferences
.
positiveResult | Whether the positive button was clicked (true), or the negative button was clicked or the dialog was canceled (false). |
---|
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.
Shows the dialog associated with this Preference. This is normally initiated automatically on clicking on the preference. Call this method if you need to show the dialog on some other event.
state | Optional instance state to restore on the dialog |
---|