Android Guides | Samples

Android.App.Dialog Class

Base class for Dialogs.

See Also: Dialog

Syntax

[Android.Runtime.Register("android/app/Dialog", DoNotGenerateAcw=true)]
public class Dialog : Object, IDialogInterface, KeyEvent+ICallback, View+IOnCreateContextMenuListener, Window+ICallback, IDisposable

Remarks

Base class for Dialogs.

Note: Activities provide a facility to manage the creation, saving and restoring of dialogs. See Activity.OnCreateDialog(Int32), Activity.OnPrepareDialog(Int32,Dialog), Activity.ShowDialog(Int32), and Activity.DismissDialog(Int32). If these methods are used, Dialog.OwnerActivity will return the Activity that managed this dialog.

Often you will want to have a Dialog display on top of the current input method, because there is no reason for it to accept text. You can do this by setting the Android.Views.WindowManagerLayoutParams.FLAG_ALT_FOCUSABLE_IM window flag (assuming your Dialog takes input focus, as it the default) with the following code:

java Example

 getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
         WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

Developer Guides

For more information about creating dialogs, read the Dialogs developer guide.

[Android Documentation]

Requirements

Namespace: Android.App
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.App.Dialog are listed below.

See Also: Object

Public Constructors

Creates a dialog window that uses the default dialog theme.
Creates a dialog window that uses a custom dialog style.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Properties

[read-only]
ActionBarActionBar. Retrieve the ActionBar attached to this dialog, if present.
[read-only]
ContextContext. Retrieve the Context this Dialog is running in.
[read-only]
CurrentFocusView. Call Window.CurrentFocus on the Window if this Activity to return the currently focused view.
[read-only]
IsShowingBoolean.
[read-only]
LayoutInflaterLayoutInflater.
OwnerActivityActivity. Returns the Activity that owns this Dialog.
VolumeControlStreamStream.
[read-only]
WindowWindow. Retrieve the current Window for the activity.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

AddContentView(View, ViewGroup+LayoutParams)
Add an additional content view to the screen.
Cancel()
Cancel the dialog.
CloseOptionsMenu()
Create()
Forces immediate creation of the dialog.
Dismiss()
Dismiss this dialog, removing it from the screen.
DispatchGenericMotionEvent(MotionEvent) : Boolean
Called to process generic motion events.
DispatchKeyEvent(KeyEvent) : Boolean
Called to process key events.
DispatchKeyShortcutEvent(KeyEvent) : Boolean
Called to process a key shortcut event.
DispatchPopulateAccessibilityEvent(AccessibilityEvent) : Boolean
Called to process population of AccessibilityEvents.
DispatchTouchEvent(MotionEvent) : Boolean
Called to process touch screen events.
DispatchTrackballEvent(MotionEvent) : Boolean
Called to process trackball events.
FindViewById(Int32) : View
Finds a child view with the given identifier.
FindViewById<T>(Int32) : T
Hide()
Hide the dialog, but do not dismiss it.
InvalidateOptionsMenu()
OnActionModeFinished(ActionMode)
Called when an action mode has been finished.
OnActionModeStarted(ActionMode)
Called when an action mode has been started.
OnAttachedToWindow()
Called when the window has been attached to the window manager.
OnBackPressed()
Called when the dialog has detected the user's press of the back key.
OnContentChanged()
This hook is called whenever the content view of the screen changes (due to a call to Android.Views.Window.SetContentView(Android.Views.View, .LayoutParams) or Android.Views.Window.AddContentView(Android.Views.View, .LayoutParams)).
OnContextItemSelected(IMenuItem) : Boolean
OnContextMenuClosed(IMenu)
OnCreateContextMenu(IContextMenu, View, IContextMenuContextMenuInfo)
Called when the context menu for this view is being built.
OnCreateOptionsMenu(IMenu) : Boolean
It is usually safe to proxy this call to the owner activity's Activity.OnCreateOptionsMenu(IMenu) if the client desires the same menu for this Dialog.
OnCreatePanelMenu(Int32, IMenu) : Boolean
Initialize the contents of the menu for panel 'featureId'.
OnCreatePanelView(Int32) : View
Instantiate the view to display in the panel for 'featureId'.
OnDetachedFromWindow()
Called when the window has been attached to the window manager.
OnGenericMotionEvent(MotionEvent) : Boolean
Called when a generic motion event was not handled by any of the views inside of the dialog.
OnKeyDown(Keycode, KeyEvent) : Boolean
A key was pressed down.
OnKeyLongPress(Keycode, KeyEvent) : Boolean
Default implementation of NoType:android/view/KeyEvent$Callback;Href=../../../reference/android/view/KeyEvent.Callback.html#onKeyLongPress(int, android.view.KeyEvent): always returns false (doesn't handle the event).
OnKeyMultiple(Keycode, Int32, KeyEvent) : Boolean
Default implementation of NoType:android/view/KeyEvent$Callback;Href=../../../reference/android/view/KeyEvent.Callback.html#onKeyMultiple(int, int, android.view.KeyEvent): always returns false (doesn't handle the event).
OnKeyShortcut(Keycode, KeyEvent) : Boolean
Called when a key shortcut event is not handled by any of the views in the Dialog.
OnKeyUp(Keycode, KeyEvent) : Boolean
A key was released.
OnMenuItemSelected(Int32, IMenuItem) : Boolean
Called when a panel's menu item has been selected by the user.
OnMenuOpened(Int32, IMenu) : Boolean
Called when a panel's menu is opened by the user.
OnOptionsItemSelected(IMenuItem) : Boolean
OnOptionsMenuClosed(IMenu)
OnPanelClosed(Int32, IMenu)
Called when a panel is being closed.
OnPrepareOptionsMenu(IMenu) : Boolean
It is usually safe to proxy this call to the owner activity's Activity.OnPrepareOptionsMenu(IMenu) if the client desires the same menu for this Dialog.
OnPreparePanel(Int32, View, IMenu) : Boolean
Prepare a panel to be displayed.
OnRestoreInstanceState(Bundle)
Restore the state of the dialog from a previously saved bundle.
OnSaveInstanceState() : Bundle
Saves the state of the dialog into a bundle.
OnSearchRequested() : Boolean
This hook is called when the user signals the desire to start a search.
OnTouchEvent(MotionEvent) : Boolean
Called when a touch screen event was not handled by any of the views under it.
OnTrackballEvent(MotionEvent) : Boolean
Called when the trackball was moved and not handled by any of the views inside of the activity.
OnWindowAttributesChanged(WindowManagerLayoutParams)
This is called whenever the current window attributes change.
OnWindowFocusChanged(Boolean)
This hook is called whenever the window focus changes.
OnWindowStartingActionMode(ActionMode+ICallback) : ActionMode
Called when an action mode is being started for this window.
OpenContextMenu(View)
OpenOptionsMenu()
RegisterForContextMenu(View)
RequestWindowFeature(Int32) : Boolean
Enable extended window features.
SetCancelable(Boolean)
Sets whether this dialog is cancelable with the Android.Views.KeyEvent.KEYCODE_BACK key.
SetCanceledOnTouchOutside(Boolean)
Sets whether this dialog is canceled when touched outside the window's bounds.
SetCancelMessage(Message)
Set a message to be sent when the dialog is canceled.
SetContentView(View)
Set the screen content to an explicit view.
SetContentView(Int32)
Set the screen content from a layout resource.
SetContentView(View, ViewGroup+LayoutParams)
Set the screen content to an explicit view.
SetDismissMessage(Message)
Set a message to be sent when the dialog is dismissed.
SetFeatureDrawable(Int32, Drawable)
Convenience for calling Window.SetFeatureDrawable(WindowFeatures,Drawable).
SetFeatureDrawableAlpha(Int32, Int32)
Convenience for calling Window.SetFeatureDrawableAlpha(WindowFeatures,Int32).
SetFeatureDrawableResource(Int32, Int32)
Convenience for calling Window.SetFeatureDrawableResource(WindowFeatures,Int32).
SetFeatureDrawableUri(Int32, Uri)
Convenience for calling Window.SetFeatureDrawableUri(WindowFeatures,Uri).
SetOnCancelListener(IDialogInterfaceOnCancelListener)
Set a listener to be invoked when the dialog is canceled.
SetOnDismissListener(IDialogInterfaceOnDismissListener)
Set a listener to be invoked when the dialog is dismissed.
SetOnKeyListener(IDialogInterfaceOnKeyListener)
Sets the callback that will be called if a key is dispatched to the dialog.
SetOnShowListener(IDialogInterfaceOnShowListener)
Sets a listener to be invoked when the dialog is shown.
SetTitle(ICharSequence)
Set the title text for this dialog's window.
SetTitle(Int32)
Set the title text for this dialog's window.
SetTitle(String)
Show()
Start the dialog and display it on screen.
TakeKeyEvents(Boolean)
Request that key events come to this dialog.
UnregisterForContextMenu(View)

Protected Methods

OnCreate(Bundle)
Similar to Activity.OnCreate(Bundle), you should initialize your dialog in this method, including calling Dialog.SetContentView(View).
OnStart()
Called when the dialog is starting.
OnStop()
Called to tell you that you're stopping.

Public Events