Java android.app AlertDialog fields, constructors, methods, implement or subclass

Example usage for Java android.app AlertDialog fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.app AlertDialog.

The text is from its open source code.

Subclass

android.app.AlertDialog has subclasses.
Click this link to see all its subclasses.

Field

intTHEME_HOLO_DARK
Special theme constant for #AlertDialog(Context,int) : use the holographic alert theme with a dark background.
intTHEME_HOLO_LIGHT
Special theme constant for #AlertDialog(Context,int) : use the holographic alert theme with a light background.
intTHEME_DEVICE_DEFAULT_LIGHT
Special theme constant for #AlertDialog(Context,int) : use the device's default alert theme with a light background.

Constructor

AlertDialog(Context context)
Creates an alert dialog that uses the default alert dialog theme.

Method

voidcancel()
Cancel the dialog.
voiddismiss()
Dismiss this dialog, removing it from the screen.
TfindViewById(@IdRes int id)
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() ).
ButtongetButton(int whichButton)
Gets one of the buttons used in the dialog.
ContextgetContext()
Retrieve the Context this Dialog is running in.
LayoutInflatergetLayoutInflater()
ListViewgetListView()
Gets the list view used in the dialog.
WindowgetWindow()
Retrieve the current Window for the activity.
booleanisShowing()
voidonWindowAttributesChanged(WindowManager.LayoutParams params)
booleanrequestWindowFeature(int featureId)
Enable extended window features.
voidsetButton(int whichButton, CharSequence text, Message msg)
Set a message to be sent when a button is pressed.
voidsetButton(int whichButton, CharSequence text, OnClickListener listener)
Set a listener to be invoked when the positive button of the dialog is pressed.
voidsetButton(CharSequence text, Message msg)
voidsetButton(CharSequence text, final OnClickListener listener)
Set a listener to be invoked when button 1 of the dialog is pressed.
voidsetButton2(CharSequence text, Message msg)
voidsetButton2(CharSequence text, final OnClickListener listener)
Set a listener to be invoked when button 2 of the dialog is pressed.
voidsetButton3(CharSequence text, Message msg)
voidsetButton3(CharSequence text, final OnClickListener listener)
Set a listener to be invoked when button 3 of the dialog is pressed.
voidsetCancelable(boolean flag)
Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.
voidsetCanceledOnTouchOutside(boolean cancel)
Sets whether this dialog is canceled when touched outside the window's bounds.
voidsetContentView(@LayoutRes int layoutResID)
Set the screen content from a layout resource.
voidsetIcon(@DrawableRes int resId)
Set resId to 0 if you don't want an icon.
voidsetIcon(Drawable icon)
voidsetInverseBackgroundForced(boolean forceInverseBackground)
voidsetMessage(CharSequence message)
voidsetOnCancelListener(@Nullable OnCancelListener listener)
Set a listener to be invoked when the dialog is canceled.
voidsetOnDismissListener(@Nullable OnDismissListener listener)
Set a listener to be invoked when the dialog is dismissed.
voidsetOnKeyListener(@Nullable OnKeyListener onKeyListener)
Sets the callback that will be called if a key is dispatched to the dialog.
voidsetOnShowListener(@Nullable OnShowListener listener)
Sets a listener to be invoked when the dialog is shown.
voidsetOwnerActivity(@NonNull Activity activity)
Sets the Activity that owns this dialog.
voidsetTitle(CharSequence title)
voidsetView(View view)
Set the view to display in that dialog.
voidsetView(View view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight, int viewSpacingBottom)
Set the view to display in that dialog, specifying the spacing to appear around that view.
voidsetVolumeControlStream(int streamType)
By default, this will use the owner Activity's suggested stream type.
voidshow()
Start the dialog and display it on screen.