Skip to content

Most visited

Recently visited

navigation

AppCompatDialog

public class AppCompatDialog
extends Dialog implements AppCompatCallback

java.lang.Object
   ↳ android.app.Dialog
     ↳ android.support.v7.app.AppCompatDialog
Known Direct Subclasses
Known Indirect Subclasses


Base class for AppCompat themed Dialogs.

Summary

Inherited constants

From interface android.content.DialogInterface

Public constructors

AppCompatDialog(Context context)
AppCompatDialog(Context context, int theme)

Protected constructors

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

Public methods

void addContentView(View view, ViewGroup.LayoutParams params)

Add an additional content view to the screen.

<T extends View> T findViewById(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()).

AppCompatDelegate getDelegate()
ActionBar getSupportActionBar()

Support library version of getActionBar().

void onSupportActionModeFinished(ActionMode mode)

Called when a support action mode has finished.

void onSupportActionModeStarted(ActionMode mode)

Called when a support action mode has been started.

ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback)

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

void setContentView(View view)

Set the screen content to an explicit view.

void setContentView(int layoutResID)

Set the screen content from a layout resource.

void setContentView(View view, ViewGroup.LayoutParams params)

Set the screen content to an explicit view.

void setTitle(CharSequence title)

Set the title text for this dialog's window.

void setTitle(int titleId)

Set the title text for this dialog's window.

boolean supportRequestWindowFeature(int featureId)

Enable extended support library window features.

Protected methods

void onCreate(Bundle savedInstanceState)

Similar to onCreate(Bundle), you should initialize your dialog in this method, including calling setContentView(View).

void onStop()

Called to tell you that you're stopping.

Inherited methods

From class android.app.Dialog
From class java.lang.Object
From interface android.content.DialogInterface
From interface android.view.Window.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.View.OnCreateContextMenuListener
From interface android.support.v7.app.AppCompatCallback

Public constructors

AppCompatDialog

added in version 23.0.0
AppCompatDialog (Context context)

Parameters
context Context

AppCompatDialog

added in version 23.0.0
AppCompatDialog (Context context, 
                int theme)

Parameters
context Context

theme int

Protected constructors

AppCompatDialog

added in version 23.0.0
AppCompatDialog (Context context, 
                boolean cancelable, 
                DialogInterface.OnCancelListener cancelListener)

Parameters
context Context

cancelable boolean

cancelListener DialogInterface.OnCancelListener

Public methods

addContentView

void addContentView (View view, 
                ViewGroup.LayoutParams params)

Add an additional content view to the screen. Added after any existing ones in the screen -- existing views are NOT removed.

Parameters
view View: The desired content to display.

params ViewGroup.LayoutParams: Layout parameters for the view.

findViewById

T findViewById (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()).

Note: In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.

Parameters
id int: the ID to search for

Returns
T a view with given ID if found, or null otherwise

getDelegate

added in version 23.0.0
AppCompatDelegate getDelegate ()

Returns
AppCompatDelegate The AppCompatDelegate being used by this Dialog.

getSupportActionBar

added in version 23.0.0
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 version 23.0.0
void onSupportActionModeFinished (ActionMode mode)

Called when a support action mode has finished.

Parameters
mode ActionMode: The action mode that just finished.

onSupportActionModeStarted

added in version 23.0.0
void onSupportActionModeStarted (ActionMode mode)

Called when a support action mode has been started.

Parameters
mode ActionMode: The new action mode.

onWindowStartingSupportActionMode

added in version 23.0.0
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
callback ActionMode.Callback: Callback to control the lifecycle of this action mode

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

setContentView

void setContentView (View view)

Set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarchy.

Parameters
view View: The desired content to display.

setContentView

void setContentView (int layoutResID)

Set the screen content from a layout resource. The resource will be inflated, adding all top-level views to the screen.

Parameters
layoutResID int: Resource ID to be inflated.

setContentView

void setContentView (View view, 
                ViewGroup.LayoutParams params)

Set the screen content to an explicit view. This view is placed directly into the screen's view hierarchy. It can itself be a complex view hierarchy.

Parameters
view View: The desired content to display.

params ViewGroup.LayoutParams: Layout parameters for the view.

setTitle

void setTitle (CharSequence title)

Set the title text for this dialog's window.

Parameters
title CharSequence: The new text to display in the title.

setTitle

void setTitle (int titleId)

Set the title text for this dialog's window. The text is retrieved from the resources with the supplied identifier.

Parameters
titleId int: the title's text resource identifier

supportRequestWindowFeature

added in version 23.0.0
boolean supportRequestWindowFeature (int featureId)

Enable extended support library window features.

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

Parameters
featureId int: The desired feature as defined in Window or WindowCompat.

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

See also:

Protected methods

onCreate

void onCreate (Bundle savedInstanceState)

Similar to onCreate(Bundle), you should initialize your dialog in this method, including calling setContentView(View).

Parameters
savedInstanceState Bundle: If this dialog is being reinitialized 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.

onStop

void onStop ()

Called to tell you that you're stopping.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.