AppCompatDialog


public class AppCompatDialog extends ComponentDialog implements AppCompatCallback

Known direct subclasses
AlertDialog

A subclass of Dialog that can display one, two or three buttons.

MediaRouteChooserDialog

This class implements the route chooser dialog for MediaRouter.

Known indirect subclasses
MediaRouteControllerDialog

This class implements the route controller dialog for MediaRouter.


Base class for AppCompat themed android.app.Dialogs.

Summary

Public constructors

AppCompatDialog(@NonNull Context context, int theme)

Protected constructors

AppCompatDialog(
    @NonNull Context context,
    boolean cancelable,
    @Nullable DialogInterface.OnCancelListener cancelListener
)

Public methods

void
void
boolean
@Nullable T
<T extends View> findViewById(@IdRes int id)
@NonNull AppCompatDelegate
ActionBar

Support library version of getActionBar.

void

Called when a support action mode has finished.

void

Called when a support action mode has been started.

@Nullable ActionMode

Called when a support action mode is being started for this window.

void
setContentView(@LayoutRes int layoutResID)
void
void
void
void
setTitle(int titleId)
boolean

Enable extended support library window features.

Protected methods

void
onCreate(Bundle savedInstanceState)
void

Inherited Constants

From android.content.DialogInterface
static final int
BUTTON1 = -1

This field is deprecated.

static final int
BUTTON2 = -2

This field is deprecated.

static final int
BUTTON3 = -3

This field is deprecated.

static final int
static final int
static final int

Inherited fields

From androidx.activity.ComponentDialog
final OnBackPressedDispatcher

The OnBackPressedDispatcher that should handle the system back button.

Inherited methods

From androidx.activity.ComponentDialog
Lifecycle
final OnBackPressedDispatcher

The OnBackPressedDispatcher that should handle the system back button.

SavedStateRegistry
void

Sets the view tree owners before setting the content view so that the inflation process and attach listeners will see them already present.

void

This method is deprecated.

Bundle
void
From android.app.Dialog
void
void
void
void
boolean
boolean
boolean
boolean
boolean
ActionBar
final Context
View
LayoutInflater
OnBackInvokedDispatcher
final Activity
final SearchEvent
final int
Window
void
boolean
void
void
void
void

This method is deprecated.

void
boolean
void
void
onCreate(Bundle savedInstanceState)
void
onCreateContextMenu(
    ContextMenu menu,
    View v,
    ContextMenu.ContextMenuInfo menuInfo
)
boolean
boolean
onCreatePanelMenu(int featureId, Menu menu)
View
onCreatePanelView(int featureId)
void
boolean
boolean
onKeyDown(int keyCode, KeyEvent event)
boolean
onKeyLongPress(int keyCode, KeyEvent event)
boolean
onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
boolean
onKeyShortcut(int keyCode, KeyEvent event)
boolean
onKeyUp(int keyCode, KeyEvent event)
boolean
onMenuItemSelected(int featureId, MenuItem item)
boolean
onMenuOpened(int featureId, Menu menu)
boolean
void
void
onPanelClosed(int featureId, Menu menu)
boolean
boolean
onPreparePanel(int featureId, View view, Menu menu)
void
onRestoreInstanceState(Bundle savedInstanceState)
Bundle
boolean
void
void
boolean
boolean
void
void
onWindowFocusChanged(boolean hasFocus)
ActionMode
void
void
void
final boolean
requestWindowFeature(int featureId)
final T
<T extends View> requireViewById(int id)
void
void
setCancelable(boolean flag)
void
setCanceledOnTouchOutside(boolean cancel)
void
setContentView(int layoutResID)
void
final void
setFeatureDrawable(int featureId, Drawable drawable)
final void
setFeatureDrawableAlpha(int featureId, int alpha)
final void
setFeatureDrawableResource(int featureId, int resId)
final void
setFeatureDrawableUri(int featureId, Uri uri)
void
void
void
void
final void
final void
setVolumeControlStream(int streamType)
void
void
takeKeyEvents(boolean get)
void
From androidx.lifecycle.LifecycleOwner
abstract Lifecycle
From androidx.savedstate.SavedStateRegistryOwner
From android.view.Window.Callback
void
onPointerCaptureChanged(boolean hasCapture)
void
onProvideKeyboardShortcuts(
    List<KeyboardShortcutGroup> data,
    Menu menu,
    int deviceId
)

Public constructors

AppCompatDialog

Added in 1.1.0
public AppCompatDialog(@NonNull Context context)

AppCompatDialog

Added in 1.1.0
public AppCompatDialog(@NonNull Context context, int theme)

Protected constructors

AppCompatDialog

Added in 1.1.0
protected AppCompatDialog(
    @NonNull Context context,
    boolean cancelable,
    @Nullable DialogInterface.OnCancelListener cancelListener
)

Public methods

addContentView

public void addContentView(@NonNull View view, ViewGroup.LayoutParams params)

dismiss

public void dismiss()

dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent event)

findViewById

public @Nullable T <T extends View> findViewById(@IdRes int id)

getDelegate

Added in 1.1.0
public @NonNull AppCompatDelegate getDelegate()
Returns
@NonNull AppCompatDelegate

The AppCompatDelegate being used by this Dialog.

getSupportActionBar

Added in 1.1.0
public ActionBar getSupportActionBar()

Support library version of getActionBar.

Retrieve a reference to this dialog's ActionBar.

Returns
ActionBar

The Dialog's ActionBar, or null if it does not have one.

onSupportActionModeFinished

Added in 1.7.0
public void onSupportActionModeFinished(ActionMode mode)

Called when a support action mode has finished.

Parameters
ActionMode mode

The action mode that just finished.

onSupportActionModeStarted

Added in 1.7.0
public void onSupportActionModeStarted(ActionMode mode)

Called when a support action mode has been started.

Parameters
ActionMode mode

The new action mode.

onWindowStartingSupportActionMode

Added in 1.7.0
public @Nullable ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback)

Called when a support action mode is being started for this window. Gives the callback an opportunity to handle the action mode in its own unique and beautiful way. If this method returns null the system can choose a way to present the mode or choose not to start the mode at all.

Parameters
ActionMode.Callback callback

Callback to control the lifecycle of this action mode

Returns
@Nullable ActionMode

The ActionMode that was started, or null if the system should present it

setContentView

public void setContentView(@LayoutRes int layoutResID)

setContentView

public void setContentView(@NonNull View view)

setContentView

public void setContentView(@NonNull View view, ViewGroup.LayoutParams params)

setTitle

public void setTitle(CharSequence title)

setTitle

public void setTitle(int titleId)

supportRequestWindowFeature

Added in 1.1.0
public boolean supportRequestWindowFeature(int featureId)

Enable extended support library window features.

This is a convenience for calling getWindow().requestFeature().

Parameters
int featureId

The desired feature as defined in android.view.Window or androidx.core.view.WindowCompat.

Returns
boolean

Returns true if the requested feature is supported and now enabled.

Protected methods

onCreate

protected void onCreate(Bundle savedInstanceState)

onStop

protected void onStop()