java.lang.Object | |||
↳ | android.app.Dialog | ||
↳ | android.support.v7.app.AppCompatDialog | ||
↳ | android.support.v7.app.AlertDialog |
Known Direct Subclasses |
A subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method. If you want to display a more complex view, look up the FrameLayout called "custom" and add your view to it:
FrameLayout fl = (FrameLayout) findViewById(android.R.id.custom); fl.addView(myView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
The AlertDialog class takes care of automatically setting
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
for you based on whether
any views in the dialog return true from View.onCheckIsTextEditor()
. Generally you want this set for a Dialog
without text editors, so that it will be placed on top of the current
input method UI. You can modify this behavior by forcing the flag to your
desired mode after calling onCreate(Bundle)
.
For more information about creating dialogs, read the Dialogs developer guide.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AlertDialog.Builder |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.content.DialogInterface
|
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct an AlertDialog that uses an explicit theme.
| |||||||||||
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets one of the buttons used in the dialog.
| |||||||||||
Gets the list view used in the dialog.
| |||||||||||
A key was pressed down.
| |||||||||||
A key was released.
| |||||||||||
Set a listener to be invoked when the positive button of the dialog is pressed.
| |||||||||||
Set a message to be sent when a button is pressed.
| |||||||||||
Set resId to 0 if you don't want an icon.
| |||||||||||
Set an icon as supplied by a theme attribute.
| |||||||||||
Set the title text for this dialog's window.
| |||||||||||
Set the view to display in that dialog, specifying the spacing to appear around that
view.
| |||||||||||
Set the view to display in that dialog.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Similar to
onCreate(Bundle) , you should initialize your dialog
in this method, including calling setContentView(View) .
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.support.v7.app.AppCompatDialog
| |||||||||||
From class
android.app.Dialog
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.support.v7.app.AppCompatCallback
| |||||||||||
From interface
android.content.DialogInterface
| |||||||||||
From interface
android.view.Window.Callback
| |||||||||||
From interface
android.view.KeyEvent.Callback
| |||||||||||
From interface
android.view.View.OnCreateContextMenuListener
|
Construct an AlertDialog that uses an explicit theme. The actual style
that an AlertDialog uses is a private implementation, however you can
here supply either the name of an attribute in the theme from which
to get the dialog's style (such as alertDialogTheme
.
Gets one of the buttons used in the dialog. Returns null if the specified
button does not exist or the dialog has not yet been fully created (for
example, via show()
or create()
).
whichButton | The identifier of the button that should be returned.
For example, this can be
BUTTON_POSITIVE . |
---|
Gets the list view used in the dialog.
ListView
from the dialog.
A key was pressed down.
If the focused view didn't want this event, this method is called.
The default implementation consumed the KEYCODE_BACK to later
handle it in onKeyUp(int, KeyEvent)
.
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
A key was released.
The default implementation handles KEYCODE_BACK to close the dialog.
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
Set a listener to be invoked when the positive button of the dialog is pressed.
whichButton | Which button to set the listener on, can be one of
BUTTON_POSITIVE ,
BUTTON_NEGATIVE , or
BUTTON_NEUTRAL |
---|---|
text | The text to display in positive button. |
listener | The DialogInterface.OnClickListener to use.
|
Set a message to be sent when a button is pressed.
whichButton | Which button to set the message for, can be one of
BUTTON_POSITIVE ,
BUTTON_NEGATIVE , or
BUTTON_NEUTRAL |
---|---|
text | The text to display in positive button. |
msg | The Message to be sent when clicked.
|
Set resId to 0 if you don't want an icon.
resId | the resourceId of the drawable to use as the icon or 0 if you don't want an icon. |
---|
Set an icon as supplied by a theme attribute. e.g. android.R.attr.alertDialogIcon
attrId | ID of a theme attribute that points to a drawable resource. |
---|
Set the title text for this dialog's window.
title | The new text to display in the title. |
---|
Set the view to display in that dialog, specifying the spacing to appear around that view.
view | The view to show in the content area of the dialog |
---|---|
viewSpacingLeft | Extra space to appear to the left of view |
viewSpacingTop | Extra space to appear above view |
viewSpacingRight | Extra space to appear to the right of view |
viewSpacingBottom | Extra space to appear below view
|
Similar to onCreate(Bundle)
, you should initialize your dialog
in this method, including calling setContentView(View)
.
savedInstanceState | If this dialog is being reinitalized after a
the hosting activity was previously shut down, holds the result from
the most recent call to onSaveInstanceState() , or null if this
is the first time.
|
---|