Android APIs
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

Summary

[Expand]
Inherited XML Attributes
From class android.app.Fragment
Constants
String ARG_KEY
[Expand]
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)
This method will be invoked when a button in the dialog is clicked.
void onCreate(Bundle savedInstanceState)
Called to do initial creation of a fragment.
Dialog onCreateDialog(Bundle savedInstanceState)
Override to build your own custom Dialog container.
abstract void onDialogClosed(boolean positiveResult)
void onDismiss(DialogInterface dialog)
This method will be invoked when the dialog is dismissed.
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.
[Expand]
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

protected static final String ARG_KEY

Constant Value: "key"

Public Constructors

public PreferenceDialogFragment ()

Public Methods

public DialogPreference getPreference ()

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

Returns

public void onClick (DialogInterface dialog, int which)

This method will be invoked when a button in the dialog is clicked.

Parameters
dialog The dialog that received the click.
which The button that was clicked (e.g. BUTTON1) or the position of the item clicked.

public void onCreate (Bundle savedInstanceState)

Called to do initial creation of a fragment. This is called after onAttach(Activity) and before onCreateView(LayoutInflater, ViewGroup, Bundle).

Note that this can be called while the fragment's activity is still in the process of being created. As such, you can not rely on things like the activity's content view hierarchy being initialized at this point. If you want to do work once the activity itself is created, see onActivityCreated(Bundle).

Parameters
savedInstanceState If the fragment is being re-created from a previous saved state, this is the state.

public Dialog onCreateDialog (Bundle savedInstanceState)

Override to build your own custom Dialog container. This is typically used to show an AlertDialog instead of a generic Dialog; when doing so, onCreateView(LayoutInflater, ViewGroup, Bundle) does not need to be implemented since the AlertDialog takes care of its own content.

This method will be called after onCreate(Bundle) and before onCreateView(LayoutInflater, ViewGroup, Bundle). The default implementation simply instantiates and returns a Dialog class.

Note: DialogFragment own the Dialog.setOnCancelListener and Dialog.setOnDismissListener callbacks. You must not set them yourself. To find out about these events, override onCancel(DialogInterface) and onDismiss(DialogInterface).

Parameters
savedInstanceState The last saved instance state of the Fragment, or null if this is a freshly created Fragment.
Returns
  • Return a new Dialog instance to be displayed by the Fragment.

public abstract void onDialogClosed (boolean positiveResult)

public void onDismiss (DialogInterface dialog)

This method will be invoked when the dialog is dismissed.

Parameters
dialog The dialog that was dismissed will be passed into the method.

Protected Methods

protected 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 The content View of the dialog, if it is custom.

protected 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.

Returns
  • The content View for the dialog.

protected 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().