DialogPreference
public abstract class DialogPreference extends Preference
EditTextPreference |
A |
ListPreference |
A |
MultiSelectListPreference |
A |
DropDownPreference |
A |
A base class for Preferences that are dialog-based. When clicked, these preferences will open a dialog showing the actual preference controls.
name android:dialogTitle
name android:dialogMessage
name android:dialogIcon
name android:dialogLayout
name android:positiveButtonText
name android:negativeButtonText
Summary
Nested types |
|---|
public interface DialogPreference.TargetFragmentInterface for |
Public constructors |
|---|
DialogPreference(@NonNull Context context) |
DialogPreference(@NonNull Context context, @Nullable AttributeSet attrs) |
DialogPreference( |
DialogPreference( |
Public methods |
|
|---|---|
@Nullable Drawable |
Returns the icon to be shown on subsequent dialogs. |
int |
Returns the layout resource that is used as the content view for subsequent dialogs. |
@Nullable CharSequence |
Returns the message to be shown on subsequent dialogs. |
@Nullable CharSequence |
Returns the title to be shown on subsequent dialogs. |
@Nullable CharSequence |
Returns the text of the negative button to be shown on subsequent dialogs. |
@Nullable CharSequence |
Returns the text of the positive button to be shown on subsequent dialogs. |
void |
setDialogIcon(@Nullable Drawable dialogIcon)Sets the icon of the dialog. |
void |
setDialogIcon(int dialogIconRes)Sets the icon (resource ID) of the dialog. |
void |
setDialogLayoutResource(int dialogLayoutResId)Sets the layout resource that is inflated as the |
void |
setDialogMessage(@Nullable CharSequence dialogMessage)Sets the message of the dialog. |
void |
setDialogMessage(int dialogMessageResId) |
void |
setDialogTitle(@Nullable CharSequence dialogTitle)Sets the title of the dialog. |
void |
setDialogTitle(int dialogTitleResId) |
void |
setNegativeButtonText(@Nullable CharSequence negativeButtonText)Sets the text of the negative button of the dialog. |
void |
setNegativeButtonText(int negativeButtonTextResId) |
void |
setPositiveButtonText(@Nullable CharSequence positiveButtonText)Sets the text of the positive button of the dialog. |
void |
setPositiveButtonText(int positiveButtonTextResId) |
Protected methods |
|
|---|---|
void |
onClick()Processes a click on the preference. |
Inherited Constants |
||
|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
DialogPreference
public DialogPreference(@NonNull Context context, @Nullable AttributeSet attrs)
DialogPreference
public DialogPreference(
@NonNull Context context,
@Nullable AttributeSet attrs,
int defStyleAttr
)
DialogPreference
public DialogPreference(
@NonNull Context context,
@Nullable AttributeSet attrs,
int defStyleAttr,
int defStyleRes
)
Public methods
getDialogIcon
public @Nullable Drawable getDialogIcon()
Returns the icon to be shown on subsequent dialogs.
getDialogLayoutResource
public int getDialogLayoutResource()
Returns the layout resource that is used as the content view for subsequent dialogs.
| Returns | |
|---|---|
int |
The layout resource |
getDialogMessage
public @Nullable CharSequence getDialogMessage()
Returns the message to be shown on subsequent dialogs.
| Returns | |
|---|---|
@Nullable CharSequence |
The message |
getDialogTitle
public @Nullable CharSequence getDialogTitle()
Returns the title to be shown on subsequent dialogs.
| Returns | |
|---|---|
@Nullable CharSequence |
The title |
getNegativeButtonText
public @Nullable CharSequence getNegativeButtonText()
Returns the text of the negative button to be shown on subsequent dialogs.
| Returns | |
|---|---|
@Nullable CharSequence |
The text of the negative button |
getPositiveButtonText
public @Nullable CharSequence getPositiveButtonText()
Returns the text of the positive button to be shown on subsequent dialogs.
| Returns | |
|---|---|
@Nullable CharSequence |
The text of the positive button |
setDialogIcon
public void setDialogIcon(@Nullable Drawable dialogIcon)
Sets the icon of the dialog. This will be shown on subsequent dialogs.
setDialogIcon
public void setDialogIcon(int dialogIconRes)
Sets the icon (resource ID) of the dialog. This will be shown on subsequent dialogs.
| Parameters | |
|---|---|
int dialogIconRes |
The icon, as a resource ID |
setDialogLayoutResource
public 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 | |
|---|---|
int dialogLayoutResId |
The layout resource ID to be inflated |
| See also | |
|---|---|
setDialogMessage |
setDialogMessage
public void setDialogMessage(@Nullable 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, include a android.widget.TextView with ID message and it will be populated with this message.
| Parameters | |
|---|---|
@Nullable CharSequence dialogMessage |
The message |
setDialogMessage
public void setDialogMessage(int dialogMessageResId)
| Parameters | |
|---|---|
int dialogMessageResId |
The dialog message as a resource |
| See also | |
|---|---|
setDialogMessage |
setDialogTitle
public void setDialogTitle(@Nullable CharSequence dialogTitle)
Sets the title of the dialog. This will be shown on subsequent dialogs.
| Parameters | |
|---|---|
@Nullable CharSequence dialogTitle |
The title |
setDialogTitle
public void setDialogTitle(int dialogTitleResId)
| Parameters | |
|---|---|
int dialogTitleResId |
The dialog title as a resource |
| See also | |
|---|---|
setDialogTitle |
setNegativeButtonText
public void setNegativeButtonText(@Nullable CharSequence negativeButtonText)
Sets the text of the negative button of the dialog. This will be shown on subsequent dialogs.
| Parameters | |
|---|---|
@Nullable CharSequence negativeButtonText |
The text of the negative button |
setNegativeButtonText
public void setNegativeButtonText(int negativeButtonTextResId)
| Parameters | |
|---|---|
int negativeButtonTextResId |
The negative button text as a resource |
| See also | |
|---|---|
setNegativeButtonText |
setPositiveButtonText
public void setPositiveButtonText(@Nullable CharSequence positiveButtonText)
Sets the text of the positive button of the dialog. This will be shown on subsequent dialogs.
| Parameters | |
|---|---|
@Nullable CharSequence positiveButtonText |
The text of the positive button |
setPositiveButtonText
public void setPositiveButtonText(int positiveButtonTextResId)
| Parameters | |
|---|---|
int positiveButtonTextResId |
The positive button text as a resource |
| See also | |
|---|---|
setPositiveButtonText |
Protected methods
onClick
protected void onClick()
Processes a click on the preference. This includes saving the value to the SharedPreferences. However, the overridden method should call callChangeListener to make sure the client wants to update the preference's state with the new value.