belongs to Maven artifact androidx.preference:preference:1.0.0-alpha1

DialogPreference

public abstract class DialogPreference
extends Preference

java.lang.Object
   ↳ androidx.preference.Preference
     ↳ androidx.preference.DialogPreference


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

Summary

Nested classes

interface DialogPreference.TargetFragment

 

Inherited XML attributes

Inherited constants

Public constructors

DialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
DialogPreference(Context context, AttributeSet attrs, int defStyleAttr)
DialogPreference(Context context, AttributeSet attrs)
DialogPreference(Context context)

Public methods

Drawable getDialogIcon()

Returns the icon to be shown on subsequent dialogs.

int getDialogLayoutResource()

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

CharSequence getDialogMessage()

Returns the message to be shown on subsequent dialogs.

CharSequence getDialogTitle()

Returns the title to be shown on subsequent dialogs.

CharSequence getNegativeButtonText()

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

CharSequence getPositiveButtonText()

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

void setDialogIcon(int dialogIconRes)

Sets the icon (resource ID) of the dialog.

void setDialogIcon(Drawable dialogIcon)

Sets the icon of the dialog.

void setDialogLayoutResource(int dialogLayoutResId)

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

void setDialogMessage(CharSequence dialogMessage)

Sets the message of the dialog.

void setDialogMessage(int dialogMessageResId)
void setDialogTitle(int dialogTitleResId)
void setDialogTitle(CharSequence dialogTitle)

Sets the title of the dialog.

void setNegativeButtonText(CharSequence negativeButtonText)

Sets the text of the negative button of the dialog.

void setNegativeButtonText(int negativeButtonTextResId)
void setPositiveButtonText(int positiveButtonTextResId)
void setPositiveButtonText(CharSequence positiveButtonText)

Sets the text of the positive button of the dialog.

Protected methods

void onClick()

Processes a click on the preference.

Inherited methods

Public constructors

DialogPreference

DialogPreference (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

DialogPreference

DialogPreference (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

DialogPreference

DialogPreference (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

DialogPreference

DialogPreference (Context context)

Parameters
context Context

Public methods

getDialogIcon

Drawable getDialogIcon ()

Returns the icon to be shown on subsequent dialogs.

Returns
Drawable The icon, as a Drawable.

getDialogLayoutResource

int getDialogLayoutResource ()

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

Returns
int The layout resource.

getDialogMessage

CharSequence getDialogMessage ()

Returns the message to be shown on subsequent dialogs.

Returns
CharSequence The message.

getDialogTitle

CharSequence getDialogTitle ()

Returns the title to be shown on subsequent dialogs.

Returns
CharSequence The title.

getNegativeButtonText

CharSequence getNegativeButtonText ()

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

Returns
CharSequence The text of the negative button.

getPositiveButtonText

CharSequence getPositiveButtonText ()

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

Returns
CharSequence The text of the positive button.

setDialogIcon

void setDialogIcon (int dialogIconRes)

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

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

setDialogIcon

void setDialogIcon (Drawable dialogIcon)

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

Parameters
dialogIcon Drawable: The icon, as a Drawable.

setDialogLayoutResource

void setDialogLayoutResource (int dialogLayoutResId)

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

void setDialogMessage (CharSequence dialogMessage)

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

Parameters
dialogMessage CharSequence: The message.

setDialogMessage

void setDialogMessage (int dialogMessageResId)

Parameters
dialogMessageResId int: The dialog message as a resource.

setDialogTitle

void setDialogTitle (int dialogTitleResId)

Parameters
dialogTitleResId int: The dialog title as a resource.

setDialogTitle

void setDialogTitle (CharSequence dialogTitle)

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

Parameters
dialogTitle CharSequence: The title.

setNegativeButtonText

void setNegativeButtonText (CharSequence negativeButtonText)

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.

setNegativeButtonText

void setNegativeButtonText (int negativeButtonTextResId)

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

setPositiveButtonText

void setPositiveButtonText (int positiveButtonTextResId)

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

setPositiveButtonText

void setPositiveButtonText (CharSequence positiveButtonText)

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

onClick

void onClick ()

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.