Skip to content

Most visited

Recently visited

navigation
added in version 24.1.0
belongs to Maven artifact com.android.support:preference-v14:27.0.0

PreferenceDialogFragment

public abstract class PreferenceDialogFragment
extends DialogFragment implements DialogInterface.OnClickListener

java.lang.Object
   ↳ android.app.Fragment
     ↳ android.app.DialogFragment
       ↳ android.support.v14.preference.PreferenceDialogFragment
Known Direct Subclasses


Abstract base class which presents a dialog associated with a DialogPreference. Since the preference object may not be available during fragment re-creation, the necessary information for displaying the dialog is read once during the initial call to onCreate(Bundle) and saved/restored in the saved instance state. Custom subclasses should also follow this pattern.

Summary

Constants

String ARG_KEY

Inherited constants

From class android.app.DialogFragment
From interface android.content.ComponentCallbacks2

Public constructors

PreferenceDialogFragment()

Public methods

DialogPreference getPreference()

Get the preference that requested this dialog.

void onClick(DialogInterface dialog, int which)
void onCreate(Bundle savedInstanceState)
Dialog onCreateDialog(Bundle savedInstanceState)
abstract void onDialogClosed(boolean positiveResult)
void onDismiss(DialogInterface dialog)
void onSaveInstanceState(Bundle outState)

Protected methods

void onBindDialogView(View view)

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

View onCreateDialogView(Context context)

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

void onPrepareDialogBuilder(AlertDialog.Builder builder)

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

Inherited methods

From class android.app.DialogFragment
From class android.app.Fragment
From class java.lang.Object
From interface android.content.DialogInterface.OnCancelListener
From interface android.content.DialogInterface.OnDismissListener
From interface android.content.ComponentCallbacks2
From interface android.view.View.OnCreateContextMenuListener
From interface android.content.DialogInterface.OnClickListener
From interface android.content.ComponentCallbacks

Constants

ARG_KEY

added in version 24.1.0
String ARG_KEY

Constant Value: "key"

Public constructors

PreferenceDialogFragment

added in version 24.1.0
PreferenceDialogFragment ()

Public methods

getPreference

added in version 24.1.0
DialogPreference getPreference ()

Get the preference that requested this dialog. Available after onCreate(Bundle) has been called on the PreferenceFragment which launched this dialog.

Returns
DialogPreference The DialogPreference associated with this dialog.

onClick

added in version 24.1.0
void onClick (DialogInterface dialog, 
                int which)

Parameters
dialog DialogInterface

which int

onCreate

void onCreate (Bundle savedInstanceState)

Parameters
savedInstanceState Bundle

onCreateDialog

Dialog onCreateDialog (Bundle savedInstanceState)

Parameters
savedInstanceState Bundle

Returns
Dialog

onDialogClosed

added in version 24.1.0
void onDialogClosed (boolean positiveResult)

Parameters
positiveResult boolean

onDismiss

void onDismiss (DialogInterface dialog)

Parameters
dialog DialogInterface

onSaveInstanceState

void onSaveInstanceState (Bundle outState)

Parameters
outState Bundle

Protected methods

onBindDialogView

added in version 24.1.0
void onBindDialogView (View view)

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

Make sure to call through to the superclass implementation.

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

onCreateDialogView

added in version 24.1.0
View onCreateDialogView (Context context)

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.

Parameters
context Context

Returns
View The content View for the dialog.

See also:

onPrepareDialogBuilder

added in version 24.1.0
void onPrepareDialogBuilder (AlertDialog.Builder builder)

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

Do not create() or show().

Parameters
builder AlertDialog.Builder

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)