AlertDialog
open class AlertDialog : AppCompatDialog, DialogInterface
kotlin.Any | |||
↳ | android.app.Dialog | ||
↳ | androidx.appcompat.app.AppCompatDialog | ||
↳ | androidx.appcompat.app.AlertDialog |
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 = findViewById(android.R.id.custom); fl.addView(myView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
The AlertDialog class takes care of automatically setting android.view.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.
Summary
Nested classes | |
---|---|
open |
Protected constructors | |
---|---|
Construct an AlertDialog that uses an explicit theme. |
|
<init>(@NonNull context: Context, cancelable: Boolean, @Nullable cancelListener: OnCancelListener?) |
Public methods | |
---|---|
open Button! |
Gets one of the buttons used in the dialog. |
open ListView! |
Gets the list view used in the dialog. |
open Boolean | |
open Boolean | |
open Unit |
setButton(whichButton: Int, text: CharSequence!, msg: Message!) Sets a message to be sent when a button is pressed. |
open Unit |
setButton(whichButton: Int, text: CharSequence!, listener: OnClickListener!) Sets a listener to be invoked when the positive button of the dialog is pressed. |
open Unit |
setButton(whichButton: Int, text: CharSequence!, icon: Drawable!, listener: OnClickListener!) Sets an icon to be displayed along with the button text and a listener to be invoked when the positive button of the dialog is pressed. |
open Unit |
setCustomTitle(customTitleView: View!) This method has no effect if called after |
open Unit |
Set resId to 0 if you don't want an icon. |
open Unit |
Set the |
open Unit |
setIconAttribute(attrId: Int) Sets an icon as supplied by a theme attribute. |
open Unit |
setMessage(message: CharSequence!) Sets the message to display. |
open Unit |
setTitle(title: CharSequence?) |
open Unit |
Set the view to |