Added in API level 1
Deprecated in API level 29

DialogPreference


abstract class DialogPreference : Preference, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, PreferenceManager.OnActivityDestroyListener
EditTextPreference

A Preference that allows for string input.

ListPreference

A Preference that displays a list of entries as a dialog.

MultiSelectListPreference

A Preference that displays a list of entries as a dialog.


A base class for Preference objects that are dialog-based. These preferences will, when clicked, open a dialog showing the actual preference controls.

Summary

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.
Inherited XML attributes
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.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

May be an integer value, such as "100".

May be a boolean value, such as "true" or "false".

May be a floating point value, such as "1.2".

android:dependency

The key of another Preference that this Preference will depend on. If the other Preference is not set or is off, this Preference will be disabled.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:enabled

Whether the Preference is enabled.

May be a boolean value, such as "true" or "false".

android:fragment

When used inside of a modern PreferenceActivity, this declares a new PreferenceFragment to be shown when the user selects this item.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:icon

The optional icon for the preference.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:iconSpaceReserved

Whether the space for the preference icon view will be reserved. By default, preference icon view visibility will be set to GONE when there is no icon provided, so the default value of this attribute is false.

May be a boolean value, such as "true" or "false".

android:key

The key to store the Preference value.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:layout

The layout for the Preference in a PreferenceActivity screen. This should rarely need to be changed, look at widgetLayout instead.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:order

The order for the Preference (lower values are to be ordered first). If this is not specified, the default ordering will be alphabetic.

May be an integer value, such as "100".

android:persistent

Whether the Preference stores its value to the storage.

May be a boolean value, such as "true" or "false".

android:recycleEnabled

Whether the preference has enabled to have its view recycled when used in the list view. This is true by default.

May be a boolean value, such as "true" or "false".

android:selectable

Whether the Preference is selectable.

May be a boolean value, such as "true" or "false".

android:shouldDisableView

Whether the view of this Preference should be disabled when this Preference is disabled.

May be a boolean value, such as "true" or "false".

android:singleLineTitle

Whether to use single line for the preference title text. By default, preference title will be constrained to one line, so the default value of this attribute is true.

May be a boolean value, such as "true" or "false".

android:summary

The summary for the Preference. In API 25 and earlier, this value is read as a plain string with styling information stripped.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:title

The title for the Preference. In API 25 and earlier, this value is read as a plain string with styling information stripped.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:widgetLayout

The layout for the controllable widget portion of a Preference. This is inflated into the layout for a Preference and should be used more frequently than the layout attribute. For example, a checkbox preference would specify a custom layout (consisting of just the CheckBox) here.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Inherited constants
Int DEFAULT_ORDER

Specify for setOrder(int) if a specific order is not required.

Public constructors

DialogPreference(context: Context!, attrs: AttributeSet!)

DialogPreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

DialogPreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Dialog!

Gets the dialog that is shown by this preference.

open Drawable!

Returns the icon to be shown on subsequent dialogs.

open Int

Returns the layout resource that is used as the content View for subsequent dialogs.

open CharSequence!

Returns the message to be shown on subsequent dialogs.

open CharSequence!

Returns the title to be shown on subsequent dialogs.

open CharSequence!

Returns the text of the negative button to be shown on subsequent dialogs.

open CharSequence!

Returns the text of the positive button to be shown on subsequent dialogs.

open Unit

See Activity's onDestroy.

open Unit
onClick(dialog: DialogInterface!, which: Int)

open Unit

open Unit
setDialogIcon(dialogIcon: Drawable!)

Sets the icon of the dialog.

open Unit
setDialogIcon(dialogIconRes: Int)

Sets the icon (resource ID) of the dialog.

open Unit
setDialogLayoutResource(dialogLayoutResId: Int)

Sets the layout resource that is inflated as the View to be shown as the content View of subsequent dialogs.

open Unit
setDialogMessage(dialogMessageResId: Int)

open Unit
setDialogMessage(dialogMessage: CharSequence!)

Sets the message of the dialog.

open Unit
setDialogTitle(dialogTitleResId: Int)

open Unit

Sets the title of the dialog.

open Unit
setNegativeButtonText(negativeButtonTextResId: Int)

open Unit
setNegativeButtonText(negativeButtonText: CharSequence!)

Sets the text of the negative button of the dialog.

open Unit
setPositiveButtonText(positiveButtonTextResId: Int)

open Unit
setPositiveButtonText(positiveButtonText: CharSequence!)

Sets the text of the positive button of the dialog.

Protected methods
open Unit

Binds views in the content View of the dialog to data.

open Unit

open View!

Creates the content view for the dialog (if a custom content view is required).

open Unit
onDialogClosed(positiveResult: Boolean)

Called when the dialog is dismissed and should be used to save data to the SharedPreferences.

open Unit

Prepares the dialog builder to be shown when the preference is clicked.

open Unit

open Parcelable!

open Unit
showDialog(state: Bundle!)

Shows the dialog associated with this Preference.

Inherited functions
Boolean callChangeListener(newValue: Any!)

Call this method after the user changes the preference, but before the internal state is set. This allows the client to ignore the user value.

Int compareTo(other: Preference!)

Compares Preference objects based on order (if set), otherwise alphabetically on the titles.

Preference! findPreferenceInHierarchy(key: String!)

Finds a Preference in this hierarchy (the whole thing, even above/below your PreferenceScreen screen break) with the given key.

This only functions after we have been attached to a hierarchy.

Context! getContext()

Returns the android.content.Context of this Preference. Each Preference in a Preference hierarchy can be from different Context (for example, if multiple activities provide preferences into a single PreferenceActivity). This Context will be used to save the Preference values.

String! getDependency()

Returns the key of the dependency on this Preference.

SharedPreferences.Editor! getEditor()

Returns an SharedPreferences.Editor where this Preference can save its value(s). Usually it's easier to use one of the helper save methods: persistBoolean(boolean), persistFloat(float), persistInt(int), persistLong(long), persistString(java.lang.String). To read values, see getSharedPreferences(). If shouldCommit() returns true, it is this Preference's responsibility to commit.

In some cases, writes to this will not be committed right away and hence not show up in the SharedPreferences, this is intended behavior to improve performance.

Bundle! getExtras()

Return the extras Bundle object associated with this preference, creating a new Bundle if there currently isn't one. You can use this to get and set individual extra key/value pairs.

String! getFragment()

Return the fragment class name associated with this Preference.

Drawable! getIcon()

Returns the icon of this Preference.

Intent! getIntent()

Return the Intent associated with this Preference.

String! getKey()

Gets the key for this Preference, which is also the key used for storing values into SharedPreferences or PreferenceDataStore.

Int getLayoutResource()

Gets the layout resource that will be shown as the View for this Preference.

Preference.OnPreferenceChangeListener! getOnPreferenceChangeListener()

Returns the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).

Preference.OnPreferenceClickListener! getOnPreferenceClickListener()

Returns the callback to be invoked when this Preference is clicked.

Int getOrder()

Gets the order of this Preference with respect to other Preference objects on the same level.

PreferenceGroup? getParent()

Returns the PreferenceGroup which is this Preference assigned to or null if this preference is not assigned to any group or is a root Preference.

Boolean getPersistedBoolean(defaultReturnValue: Boolean)

Attempts to get a persisted boolean if this Preference is persistent.

Float getPersistedFloat(defaultReturnValue: Float)

Attempts to get a persisted float if this Preference is persistent.

Int getPersistedInt(defaultReturnValue: Int)

Attempts to get a persisted int if this Preference is persistent.

Long getPersistedLong(defaultReturnValue: Long)

Attempts to get a persisted long if this Preference is persistent.

String! getPersistedString(defaultReturnValue: String!)

Attempts to get a persisted String if this Preference is persistent.

MutableSet<String!>! getPersistedStringSet(defaultReturnValue: MutableSet<String!>!)

Attempts to get a persisted set of Strings if this Preference is persistent.

PreferenceDataStore? getPreferenceDataStore()

Returns PreferenceDataStore used by this Preference. Returns null if android.content.SharedPreferences is used instead.

By default preferences always use android.content.SharedPreferences. To make this preference to use the PreferenceDataStore you need to assign your implementation to the Preference itself via setPreferenceDataStore(android.preference.PreferenceDataStore) or to its PreferenceManager via PreferenceManager.setPreferenceDataStore(PreferenceDataStore).

PreferenceManager! getPreferenceManager()

Gets the PreferenceManager that manages this Preference object's tree.

SharedPreferences! getSharedPreferences()

Returns the SharedPreferences where this Preference can read its value(s). Usually, it's easier to use one of the helper read methods: getPersistedBoolean(boolean), getPersistedFloat(float), getPersistedInt(int), getPersistedLong(long), getPersistedString(java.lang.String). To save values, see getEditor().

In some cases, writes to the getEditor() will not be committed right away and hence not show up in the returned SharedPreferences, this is intended behavior to improve performance.

Boolean getShouldDisableView()

Checks whether this Preference should disable its view when it's action is disabled.

CharSequence! getSummary()

Returns the summary of this Preference.

CharSequence! getTitle()

Returns the title of this Preference.

Int getTitleRes()

Returns the title resource ID of this Preference. If the title did not come from a resource, 0 is returned.

View! getView(convertView: View!, parent: ViewGroup!)

Gets the View that will be shown in the PreferenceActivity.

Int getWidgetLayoutResource()

Gets the layout resource for the controllable widget portion of this Preference.

Boolean hasKey()

Checks whether this Preference has a valid key.

Boolean isEnabled()

Checks whether this Preference should be enabled in the list.

Boolean isIconSpaceReserved()

Gets whether the space this preference icon view is reserved.

Boolean isPersistent()

Checks whether this Preference is persistent. If it is, it stores its value(s) into the persistent SharedPreferences storage by default or into PreferenceDataStore if assigned.

Boolean isRecycleEnabled()

Checks whether this Preference has enabled to have its view recycled when used in the list view.

Boolean isSelectable()

Checks whether this Preference should be selectable in the list.

Boolean isSingleLineTitle()

Gets whether the title of this preference is constrained to a single line.

Unit notifyChanged()

Should be called when the data of this Preference has changed.

Unit notifyDependencyChange(disableDependents: Boolean)

Notifies any listening dependents of a change that affects the dependency.

Unit notifyHierarchyChanged()

Should be called when a Preference has been added/removed from this group, or the ordering should be re-evaluated.

Unit onAttachedToActivity()

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.

Unit onAttachedToHierarchy(preferenceManager: PreferenceManager!)

Called when this Preference has been attached to a Preference hierarchy. Make sure to call the super implementation.

Unit onBindView(view: View!)

Binds the created View to the data for this Preference.

This is a good place to grab references to custom Views in the layout and set properties on them.

Make sure to call through to the superclass's implementation.
If you override this method you must call through to the superclass implementation.

View! onCreateView(parent: ViewGroup!)

Creates the View to be shown for this Preference in the PreferenceActivity. The default behavior is to inflate the main layout of this Preference (see setLayoutResource(int). If changing this behavior, please specify a ViewGroup with ID android.R.id#widget_frame.

Make sure to call through to the superclass's implementation.
If you override this method you must call through to the superclass implementation.

Unit onDependencyChanged(dependency: Preference!, disableDependent: Boolean)

Called when the dependency changes.

Any! onGetDefaultValue(a: TypedArray!, index: Int)

Called when a Preference is being inflated and the default value attribute needs to be read. Since different Preference types have different value types, the subclass should get and return the default value which will be its value type.

For example, if the value type is String, the body of the method would proxy to TypedArray.getString(int).

Unit onParentChanged(parent: Preference!, disableChild: Boolean)

Called when the implicit parent dependency changes.

Unit 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.
If you override this method you must call through to the superclass implementation.

Unit onSetInitialValue(restorePersistedValue: Boolean, defaultValue: Any!)

Implement this to set the initial value of the Preference.

If restorePersistedValue is true, you should restore the Preference value from the android.content.SharedPreferences. If restorePersistedValue is false, you should set the Preference value to defaultValue that is given (and possibly store to SharedPreferences if shouldPersist() is true).

In case of using PreferenceDataStore, the restorePersistedValue is always true. But the default value (if provided) is set.

This may not always be called. One example is if it should not persist but there is no default value given.

Bundle! peekExtras()

Return the extras Bundle object associated with this preference, returning null if there is not currently one.

Boolean persistBoolean(value: Boolean)

Attempts to persist a boolean if this Preference is persistent.

Boolean persistFloat(value: Float)

Attempts to persist a long if this Preference is persistent.

Boolean persistInt(value: Int)

Attempts to persist an int if this Preference is persistent.

Boolean persistLong(value: Long)

Attempts to persist a long if this Preference is persistent.

Boolean persistString(value: String!)

Attempts to persist a String if this Preference is persistent.

Boolean persistStringSet(values: MutableSet<String!>!)

Attempts to persist a set of Strings if this Preference is persistent.

Unit restoreHierarchyState(container: Bundle!)

Restore this Preference hierarchy's previously saved state from the given container.

Unit saveHierarchyState(container: Bundle!)

Store this Preference hierarchy's frozen state into the given container.

Unit setDefaultValue(defaultValue: Any!)

Sets the default value for this Preference, which will be set either if persistence is off or persistence is on and the preference is not found in the persistent storage.

Unit setDependency(dependencyKey: String!)

Sets the key of a Preference that this Preference will depend on. If that Preference is not set or is off, this Preference will be disabled.

Unit setEnabled(enabled: Boolean)

Sets whether this Preference is enabled. If disabled, it will not handle clicks.

Unit setFragment(fragment: String!)

Sets the class name of a fragment to be shown when this Preference is clicked.

Unit setIcon(icon: Drawable!)

Sets the icon for this Preference with a Drawable. This icon will be placed into the ID android.R.id#icon within the View created by onCreateView(android.view.ViewGroup).

Unit setIcon(iconResId: Int)

Sets the icon for this Preference with a resource ID.

Unit setIconSpaceReserved(iconSpaceReserved: Boolean)

Sets whether to reserve the space of this Preference icon view when no icon is provided.

Unit setIntent(intent: Intent!)

Sets an Intent to be used for Context.startActivity(Intent) when this Preference is clicked.

Unit setKey(key: String!)

Sets the key for this Preference, which is used as a key to the SharedPreferences or PreferenceDataStore. This should be unique for the package.

Unit setLayoutResource(layoutResId: Int)

Sets the layout resource that is inflated as the View to be shown for this Preference. In most cases, the default layout is sufficient for custom Preference objects and only the widget layout needs to be changed.

This layout should contain a ViewGroup with ID android.R.id#widget_frame to be the parent of the specific widget for this Preference. It should similarly contain android.R.id#title and android.R.id#summary.

Unit setOnPreferenceChangeListener(onPreferenceChangeListener: Preference.OnPreferenceChangeListener!)

Sets the callback to be invoked when this Preference is changed by the user (but before the internal state has been updated).

Unit setOnPreferenceClickListener(onPreferenceClickListener: Preference.OnPreferenceClickListener!)

Sets the callback to be invoked when this Preference is clicked.

Unit setOrder(order: Int)

Sets the order of this Preference with respect to other Preference objects on the same level. If this is not specified, the default behavior is to sort alphabetically. The PreferenceGroup.setOrderingAsAdded(boolean) can be used to order Preference objects based on the order they appear in the XML.

Unit setPersistent(persistent: Boolean)

Sets whether this Preference is persistent. When persistent, it stores its value(s) into the persistent SharedPreferences storage by default or into PreferenceDataStore if assigned.

Unit setPreferenceDataStore(dataStore: PreferenceDataStore!)

Sets a PreferenceDataStore to be used by this Preference instead of using android.content.SharedPreferences.

The data store will remain assigned even if the Preference is moved around the preference hierarchy. It will also override a data store propagated from the PreferenceManager that owns this Preference.

Unit setRecycleEnabled(enabled: Boolean)

Sets whether this Preference has enabled to have its view recycled when used in the list view. By default the recycling is enabled.

The value can be changed only before this preference is added to the preference hierarchy.

If view recycling is not allowed then each time the list view populates this preference the getView(android.view.View,android.view.ViewGroup) method receives a null convert view and needs to recreate the view. Otherwise view gets recycled and only onBindView(android.view.View) gets called.
If you override this method you must call through to the superclass implementation.

Unit setSelectable(selectable: Boolean)

Sets whether this Preference is selectable.

Unit setShouldDisableView(shouldDisableView: Boolean)

Sets whether this Preference should disable its view when it gets disabled.

For example, set this and setEnabled(boolean) to false for preferences that are only displaying information and 1) should not be clickable 2) should not have the view set to the disabled state.

Unit setSingleLineTitle(singleLineTitle: Boolean)

Sets whether to constrain the title of this Preference to a single line instead of letting it wrap onto multiple lines.

Unit setSummary(summaryResId: Int)

Sets the summary for this Preference with a resource ID.

Unit setSummary(summary: CharSequence!)

Sets the summary for this Preference with a CharSequence.

Unit setTitle(titleResId: Int)

Sets the title for this Preference with a resource ID.

Unit setTitle(title: CharSequence!)

Sets the title for this Preference with a CharSequence. This title will be placed into the ID android.R.id#title within the View created by onCreateView(android.view.ViewGroup).

Unit setWidgetLayoutResource(widgetLayoutResId: Int)

Sets the layout for the controllable widget portion of this Preference. This is inflated into the main layout. For example, a CheckBoxPreference would specify a custom layout (consisting of just the CheckBox) here, instead of creating its own main layout.

Boolean shouldCommit()

Returns whether the Preference should commit its saved value(s) in getEditor(). This may return false in situations where batch committing is being done (by the manager) to improve performance.

If this preference is using PreferenceDataStore this value is irrelevant.

Boolean shouldDisableDependents()

Checks whether this preference's dependents should currently be disabled.

Boolean shouldPersist()

Checks whether, at the given time this method is called, this Preference should store/restore its value(s) into the SharedPreferences or into PreferenceDataStore if assigned. This, at minimum, checks whether this Preference is persistent and it currently has a key. Before you save/restore from the storage, check this first.

String toString()

XML attributes

android:dialogIcon

android:dialogIcon
The icon for the dialog.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:dialogLayout

android:dialogLayout
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.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:dialogMessage

android:dialogMessage
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.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:dialogTitle

android:dialogTitle
The title in the dialog.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:negativeButtonText

android:negativeButtonText
The negative button text for the dialog. Set to @null to hide the negative button.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:positiveButtonText

android:positiveButtonText
The positive button text for the dialog. Set to @null to hide the positive button.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Public constructors

DialogPreference

Added in API level 21
DialogPreference(context: Context!)

DialogPreference

Added in API level 1
DialogPreference(
    context: Context!,
    attrs: AttributeSet!)

DialogPreference

Added in API level 1
DialogPreference(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

DialogPreference

Added in API level 21
DialogPreference(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

getDialog

Added in API level 3
Deprecated in API level 29
open fun getDialog(): Dialog!

Deprecated: Deprecated in Java.

Gets the dialog that is shown by this preference.

Return
Dialog! The dialog, or null if a dialog is not being shown.

getDialogIcon

Added in API level 1
open fun getDialogIcon(): Drawable!

Deprecated: Deprecated in Java.

Returns the icon to be shown on subsequent dialogs.

Return
Drawable! The icon, as a Drawable.

getDialogLayoutResource

Added in API level 1
open fun getDialogLayoutResource(): Int

Deprecated: Deprecated in Java.

Returns the layout resource that is used as the content View for subsequent dialogs.

Return
Int The layout resource.

getDialogMessage

Added in API level 1
open fun getDialogMessage(): CharSequence!

Deprecated: Deprecated in Java.

Returns the message to be shown on subsequent dialogs.

Return
CharSequence! The message.

getDialogTitle

Added in API level 1
open fun getDialogTitle(): CharSequence!

Deprecated: Deprecated in Java.

Returns the title to be shown on subsequent dialogs.

Return
CharSequence! The title.

getNegativeButtonText

Added in API level 1
open fun getNegativeButtonText(): CharSequence!

Deprecated: Deprecated in Java.

Returns the text of the negative button to be shown on subsequent dialogs.

Return
CharSequence! The text of the negative button.

getPositiveButtonText

Added in API level 1
open fun getPositiveButtonText(): CharSequence!

Deprecated: Deprecated in Java.

Returns the text of the positive button to be shown on subsequent dialogs.

Return
CharSequence! The text of the positive button.

onActivityDestroy

Added in API level 1
open fun onActivityDestroy(): Unit

Deprecated: Deprecated in Java.

See Activity's onDestroy.

onClick

Added in API level 1
open fun onClick(
    dialog: DialogInterface!,
    which: Int
): Unit

Deprecated: Deprecated in Java.

Parameters
dialog DialogInterface!: the dialog that received the click
which Int: the button that was clicked (ex. DialogInterface.BUTTON_POSITIVE) or the position of the item clicked

onDismiss

Added in API level 1
open fun onDismiss(dialog: DialogInterface!): Unit

Deprecated: Deprecated in Java.

Parameters
dialog DialogInterface!: the dialog that was dismissed will be passed into the method

setDialogIcon

Added in API level 1
open fun setDialogIcon(dialogIcon: Drawable!): Unit

Deprecated: Deprecated in Java.

Sets the icon of the dialog. This will be shown on subsequent dialogs.

Parameters
dialogIcon Drawable!: The icon, as a Drawable.

setDialogIcon

Added in API level 1
open fun setDialogIcon(dialogIconRes: Int): Unit

Deprecated: Deprecated in Java.

Sets the icon (resource ID) of the dialog. This will be shown on subsequent dialogs.

Parameters
dialogIconRes Int: The icon, as a resource ID.

setDialogLayoutResource

Added in API level 1
open fun setDialogLayoutResource(dialogLayoutResId: Int): Unit

Deprecated: Deprecated in Java.

Sets the layout resource that is inflated as the View to be shown as the content View of subsequent dialogs.

Parameters
dialogLayoutResId Int: The layout resource ID to be inflated.

setDialogMessage

Added in API level 1
open fun setDialogMessage(dialogMessageResId: Int): Unit

Deprecated: Deprecated in Java.

Parameters
dialogMessageResId Int: The dialog message as a resource.

setDialogMessage

Added in API level 1
open fun setDialogMessage(dialogMessage: CharSequence!): Unit

Deprecated: Deprecated in Java.

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 android.R.id#message and it will be populated with this message.

Parameters
dialogMessage CharSequence!: The message.

setDialogTitle

Added in API level 1
open fun setDialogTitle(dialogTitleResId: Int): Unit

Deprecated: Deprecated in Java.

Parameters
dialogTitleResId Int: The dialog title as a resource.

setDialogTitle

Added in API level 1
open fun setDialogTitle(dialogTitle: CharSequence!): Unit

Deprecated: Deprecated in Java.

Sets the title of the dialog. This will be shown on subsequent dialogs.

Parameters
dialogTitle CharSequence!: The title.

setNegativeButtonText

Added in API level 1
open fun setNegativeButtonText(negativeButtonTextResId: Int): Unit

Deprecated: Deprecated in Java.

Parameters
negativeButtonTextResId Int: The negative button text as a resource.

setNegativeButtonText

Added in API level 1
open fun setNegativeButtonText(negativeButtonText: CharSequence!): Unit

Deprecated: Deprecated in Java.

Sets the text of the negative button of the dialog. This will be shown on subsequent dialogs.

Parameters
negativeButtonText CharSequence!: The text of the negative button.

setPositiveButtonText

Added in API level 1
open fun setPositiveButtonText(positiveButtonTextResId: Int): Unit

Deprecated: Deprecated in Java.

Parameters
positiveButtonTextResId Int: The positive button text as a resource.

setPositiveButtonText

Added in API level 1
open fun setPositiveButtonText(positiveButtonText: CharSequence!): Unit

Deprecated: Deprecated in Java.

Sets the text of the positive button of the dialog. This will be shown on subsequent dialogs.

Parameters
positiveButtonText CharSequence!: The text of the positive button.

Protected methods

onBindDialogView

Added in API level 1
protected open fun onBindDialogView(view: View!): Unit

Deprecated: Deprecated in Java.

Binds views in the content View of the dialog to data.

Make sure to call through to the superclass implementation.
If you override this method you must call through to the superclass implementation.

Parameters
view View!: The content View of the dialog, if it is custom.

onClick

Added in API level 1
protected open fun onClick(): Unit

Deprecated: Deprecated in Java.

onCreateDialogView

Added in API level 1
protected open fun onCreateDialogView(): View!

Deprecated: Deprecated in Java.

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.

Return
View! The content View for the dialog.

onDialogClosed

Added in API level 1
protected open fun onDialogClosed(positiveResult: Boolean): Unit

Deprecated: Deprecated in Java.

Called when the dialog is dismissed and should be used to save data to the SharedPreferences.

Parameters
positiveResult Boolean: Whether the positive button was clicked (true), or the negative button was clicked or the dialog was canceled (false).

onPrepareDialogBuilder

Added in API level 1
protected open fun onPrepareDialogBuilder(builder: AlertDialog.Builder!): Unit

Deprecated: Deprecated in Java.

Prepares the dialog builder to be shown when the preference is clicked. Use this to set custom properties on the dialog.

Do not AlertDialog.Builder.create() or AlertDialog.Builder.show().

onRestoreInstanceState

Added in API level 1
protected open fun onRestoreInstanceState(state: Parcelable!): Unit

Deprecated: Deprecated in Java.

Parameters
state Parcelable!: The saved state that had previously been returned by onSaveInstanceState.

onSaveInstanceState

Added in API level 1
protected open fun onSaveInstanceState(): Parcelable!

Deprecated: Deprecated in Java.

Return
Parcelable! A Parcelable object containing the current dynamic state of this Preference, or null if there is nothing interesting to save. The default implementation returns null.

showDialog

Added in API level 1
protected open fun showDialog(state: Bundle!): Unit

Deprecated: Deprecated in Java.

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.

Parameters
state Bundle!: Optional instance state to restore on the dialog