Dialog Class

Definition

Base class for Dialogs.

[Android.Runtime.Register("android/app/Dialog", DoNotGenerateAcw=true)]
public class Dialog : Java.Lang.Object, Android.Content.IDialogInterface, Android.Views.KeyEvent.ICallback, Android.Views.View.IOnCreateContextMenuListener, Android.Views.Window.ICallback, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/app/Dialog", DoNotGenerateAcw=true)>]
type Dialog = class
    inherit Object
    interface IDialogInterface
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface KeyEvent.ICallback
    interface View.IOnCreateContextMenuListener
    interface Window.ICallback
Inheritance
Dialog
Derived
Attributes
Implements

Remarks

Base class for Dialogs.

Note: Activities provide a facility to manage the creation, saving and restoring of dialogs. See Activity#onCreateDialog(int), Activity#onPrepareDialog(int, Dialog), Activity#showDialog(int), and Activity#dismissDialog(int). If these methods are used, #getOwnerActivity() 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 WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM window flag (assuming your Dialog takes input focus, as it the default) with the following code:

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

<div class="special reference"> <h3>Developer Guides</h3>

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

</div>

Java documentation for android.app.Dialog.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Dialog(Context, Boolean, EventHandler)
Dialog(Context, Boolean, IDialogInterfaceOnCancelListener)

Creates a dialog window that uses the default dialog theme.

Dialog(Context, Int32)

Creates a dialog window that uses a custom dialog style.

Dialog(Context)

Creates a dialog window that uses the default dialog theme.

Dialog(IntPtr, JniHandleOwnership)

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

Properties

ActionBar

Retrieve the ActionBar attached to this dialog, if present.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Context

Retrieve the Context this Dialog is running in.

CurrentFocus

Call android.view.Window#getCurrentFocus on the Window if this Activity to return the currently focused view.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsShowing
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
LayoutInflater
OnBackInvokedDispatcher

Returns the OnBackInvokedDispatcher instance associated with the window that this dialog is attached to.

OwnerActivity

Returns the Activity that owns this Dialog. -or- Sets the Activity that owns this dialog.

PeerReference (Inherited from Object)
SearchEvent

During the onSearchRequested() callbacks, this function will return the SearchEvent that triggered the callback, if it exists.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

VolumeControlStream

By default, this will use the owner Activity's suggested stream type.

Window

Retrieve the current Window for the activity.

Methods

AddContentView(View, ViewGroup+LayoutParams)

Add an additional content view to the screen.

Cancel()

Cancel the dialog.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CloseOptionsMenu()
Create()

Forces immediate creation of the dialog.

Dismiss()

Dismiss this dialog, removing it from the screen.

DispatchGenericMotionEvent(MotionEvent)

Called to process generic motion events.

DispatchKeyEvent(KeyEvent)

Called to process key events.

DispatchKeyShortcutEvent(KeyEvent)

Called to process a key shortcut event.

DispatchPopulateAccessibilityEvent(AccessibilityEvent)

Called to process population of AccessibilityEvents.

DispatchTouchEvent(MotionEvent)

Called to process touch screen events.

DispatchTrackballEvent(MotionEvent)

Called to process trackball events.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FindViewById(Int32)

Finds the first descendant view with the given ID or null if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via #show() or #create()).

FindViewById<T>(Int32)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Hide()

Hide the dialog, but do not dismiss it.

InvalidateOptionsMenu()
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
OnActionModeFinished(ActionMode)

To be added

        Note that if you override this method you should always call through
        to the superclass implementation by calling super.
OnActionModeStarted(ActionMode)

To be added

        Note that if you override this method you should always call through
        to the superclass implementation by calling super.
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 M:Android.Views.Window.SetContentView(Android.Views.View,.LayoutParams) or AddContentView(View, ViewGroup+LayoutParams)).

OnContextItemSelected(IMenuItem)
OnContextMenuClosed(IMenu)
OnCreate(Bundle)

Similar to Activity#onCreate, you should initialize your dialog in this method, including calling #setContentView.

OnCreateContextMenu(IContextMenu, View, IContextMenuContextMenuInfo)

Called when the context menu for this view is being built.

OnCreateOptionsMenu(IMenu)

It is usually safe to proxy this call to the owner activity's Activity#onCreateOptionsMenu(Menu) if the client desires the same menu for this Dialog.

OnCreatePanelMenu(Int32, IMenu)

Initialize the contents of the menu for panel 'featureId'.

OnCreatePanelView(Int32)

Instantiate the view to display in the panel for 'featureId'.

OnDetachedFromWindow()

Called when the window has been attached to the window manager.

OnGenericMotionEvent(MotionEvent)

Called when a generic motion event was not handled by any of the views inside of the dialog.

OnKeyDown(Keycode, KeyEvent)

A key was pressed down.

OnKeyLongPress(Keycode, KeyEvent)

Default implementation of KeyEvent.Callback#onKeyLongPress(int, KeyEvent) KeyEvent.Callback.onKeyLongPress(): always returns false (doesn't handle the event).

OnKeyMultiple(Keycode, Int32, KeyEvent)

Default implementation of KeyEvent.Callback#onKeyMultiple(int, int, KeyEvent) KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).

OnKeyShortcut(Keycode, KeyEvent)

Called when a key shortcut event is not handled by any of the views in the Dialog.

OnKeyUp(Keycode, KeyEvent)

A key was released.

OnMenuItemSelected(Int32, IMenuItem)

Called when a panel's menu item has been selected by the user.

OnMenuOpened(Int32, IMenu)

Called when a panel's menu is opened by the user.

OnOptionsItemSelected(IMenuItem)
OnOptionsMenuClosed(IMenu)
OnPanelClosed(Int32, IMenu)

Called when a panel is being closed.

OnPrepareOptionsMenu(IMenu)

It is usually safe to proxy this call to the owner activity's Activity#onPrepareOptionsMenu(Menu) if the client desires the same menu for this Dialog.

OnPreparePanel(Int32, View, IMenu)

Prepare a panel to be displayed.

OnRestoreInstanceState(Bundle)

Restore the state of the dialog from a previously saved bundle.

OnSaveInstanceState()

Saves the state of the dialog into a bundle.

OnSearchRequested()

This hook is called when the user signals the desire to start a search.

OnSearchRequested(SearchEvent)

This hook is called when the user signals the desire to start a search.

OnStart()

Called when the dialog is starting.

OnStop()

Called to tell you that you're stopping.

OnTouchEvent(MotionEvent)

Called when a touch screen event was not handled by any of the views under it.

OnTrackballEvent(MotionEvent)

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, ActionModeType)
OnWindowStartingActionMode(ActionMode+ICallback)

Called when an action mode is being started for this window.

OpenContextMenu(View)
OpenOptionsMenu()
RegisterForContextMenu(View)
RequestWindowFeature(Int32)

Enable extended window features.

RequireViewById(Int32)

Finds the first descendant view with the given ID or throws an IllegalArgumentException if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via #show() or #create()).

SetCancelable(Boolean)

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK 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(Int32)

Set the screen content from a layout resource.

SetContentView(View, ViewGroup+LayoutParams)

Set the screen content from a layout resource.

SetContentView(View)

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 android.view.Window#setFeatureDrawable(int, Drawable).

SetFeatureDrawableAlpha(Int32, Int32)

Convenience for calling android.view.Window#setFeatureDrawableAlpha.

SetFeatureDrawableResource(Int32, Int32)

Convenience for calling android.view.Window#setFeatureDrawableResource.

SetFeatureDrawableUri(Int32, Uri)

Convenience for calling android.view.Window#setFeatureDrawableUri.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
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)

Set the title text for this dialog's window.

Show()

Start the dialog and display it on screen.

TakeKeyEvents(Boolean)

Request that key events come to this dialog.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterForContextMenu(View)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Events

CancelEvent
DismissEvent
KeyPress
ShowEvent

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to