|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.app.Dialog
public class Dialog
Base class for Dialogs.
Note: Activities provide a facility to manage the creation, saving and
restoring of dialogs. See Activity.onCreateDialog(int),
Activity.onPrepareDialog(int, Dialog),
Activity.showDialog(int), and Activity.dismissDialog(int). If
these methods are used, getOwnerActivity() will return the Activity
that managed this dialog.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface android.content.DialogInterface |
|---|
DialogInterface.OnCancelListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, DialogInterface.OnKeyListener, DialogInterface.OnMultiChoiceClickListener |
| Field Summary | |
|---|---|
protected boolean |
mCancelable
This field should be made private, so it is hidden from the SDK. |
(package private) Context |
mContext
|
(package private) View |
mDecor
|
(package private) Window |
mWindow
|
(package private) WindowManager |
mWindowManager
|
| Fields inherited from interface android.content.DialogInterface |
|---|
BUTTON1, BUTTON2, BUTTON3 |
| Constructor Summary | |
|---|---|
|
Dialog(Context context)
Create a Dialog window that uses the default dialog frame style. |
protected |
Dialog(Context context,
boolean cancelable,
DialogInterface.OnCancelListener cancelListener)
|
protected |
Dialog(Context context,
boolean cancelable,
Message cancelCallback)
Deprecated. |
|
Dialog(Context context,
int theme)
Create a Dialog window that uses a custom dialog style. |
| Method Summary | |
|---|---|
void |
addContentView(View view,
ViewGroup.LayoutParams params)
Add an additional content view to the screen. |
void |
cancel()
Cancel the dialog. |
void |
closeOptionsMenu()
|
void |
dismiss()
Dismiss this dialog, removing it from the screen. |
boolean |
dispatchKeyEvent(KeyEvent event)
Called to process key events. |
(package private) void |
dispatchOnCreate(Bundle savedInstanceState)
|
boolean |
dispatchTouchEvent(MotionEvent ev)
Called to process touch screen events. |
boolean |
dispatchTrackballEvent(MotionEvent ev)
Called to process trackball events. |
View |
findViewById(int id)
Finds a view that was identified by the id attribute from the XML that was processed in onStart(). |
Context |
getContext()
Retrieve the Context this Dialog is running in. |
View |
getCurrentFocus()
Call Window.getCurrentFocus() on the
Window if this Activity to return the currently focused view. |
LayoutInflater |
getLayoutInflater()
|
Activity |
getOwnerActivity()
Returns the Activity that owns this Dialog. |
int |
getVolumeControlStream()
|
Window |
getWindow()
Retrieve the current Window for the activity. |
void |
hide()
Hide the dialog, but do not dismiss it. |
boolean |
isShowing()
|
void |
onContentChanged()
This hook is called whenever the content view of the screen changes (due to a call to Window.setContentView or
Window.addContentView). |
boolean |
onContextItemSelected(MenuItem item)
|
void |
onContextMenuClosed(Menu menu)
|
protected void |
onCreate(Bundle savedInstanceState)
Similar to Activity.onCreate(android.os.Bundle), you should initialized your dialog
in this method, including calling setContentView(int). |
void |
onCreateContextMenu(ContextMenu menu,
View v,
ContextMenu.ContextMenuInfo menuInfo)
Called when the context menu for this view is being built. |
boolean |
onCreateOptionsMenu(Menu menu)
It is usually safe to proxy this call to the owner activity's Activity.onCreateOptionsMenu(Menu) if the client desires the same
menu for this Dialog. |
boolean |
onCreatePanelMenu(int featureId,
Menu menu)
Initialize the contents of the menu for panel 'featureId'. |
View |
onCreatePanelView(int featureId)
Instantiate the view to display in the panel for 'featureId'. |
boolean |
onKeyDown(int keyCode,
KeyEvent event)
A key was pressed down. |
boolean |
onKeyMultiple(int keyCode,
int repeatCount,
KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle
the event). |
boolean |
onKeyUp(int keyCode,
KeyEvent event)
A key was released. |
boolean |
onMenuItemSelected(int featureId,
MenuItem item)
Called when a panel's menu item has been selected by the user. |
boolean |
onMenuOpened(int featureId,
Menu menu)
Called when a panel's menu is opened by the user. |
boolean |
onOptionsItemSelected(MenuItem item)
|
void |
onOptionsMenuClosed(Menu menu)
|
void |
onPanelClosed(int featureId,
Menu menu)
Called when a panel is being closed. |
boolean |
onPrepareOptionsMenu(Menu menu)
It is usually safe to proxy this call to the owner activity's Activity.onPrepareOptionsMenu(Menu) if the client desires the
same menu for this Dialog. |
boolean |
onPreparePanel(int featureId,
View view,
Menu menu)
Prepare a panel to be displayed. |
void |
onRestoreInstanceState(Bundle savedInstanceState)
Restore the state of the dialog from a previously saved bundle. |
Bundle |
onSaveInstanceState()
Saves the state of the dialog into a bundle. |
boolean |
onSearchRequested()
This hook is called when the user signals the desire to start a search. |
protected void |
onStart()
Called when the dialog is starting. |
protected void |
onStop()
Called to tell you that you're stopping. |
boolean |
onTouchEvent(MotionEvent event)
Called when a touch screen event was not handled by any of the views under it. |
boolean |
onTrackballEvent(MotionEvent event)
Called when the trackball was moved and not handled by any of the views inside of the activity. |
void |
onWindowAttributesChanged(WindowManager.LayoutParams params)
This is called whenever the current window attributes change. |
void |
onWindowFocusChanged(boolean hasFocus)
This hook is called whenever the window focus changes. |
void |
openContextMenu(View view)
|
void |
openOptionsMenu()
|
void |
registerForContextMenu(View view)
|
boolean |
requestWindowFeature(int featureId)
Enable extended window features. |
void |
setCancelable(boolean flag)
Sets whether this dialog is cancelable with the BACK key. |
void |
setCanceledOnTouchOutside(boolean cancel)
Sets whether this dialog is canceled when touched outside the window's bounds. |
void |
setCancelMessage(Message msg)
Set a message to be sent when the dialog is canceled. |
void |
setContentView(int layoutResID)
Set the screen content from a layout resource. |
void |
setContentView(View view)
Set the screen content to an explicit view. |
void |
setContentView(View view,
ViewGroup.LayoutParams params)
Set the screen content to an explicit view. |
void |
setDismissMessage(Message msg)
Set a message to be sent when the dialog is dismissed. |
void |
setFeatureDrawable(int featureId,
Drawable drawable)
Convenience for calling Window.setFeatureDrawable(int, Drawable). |
void |
setFeatureDrawableAlpha(int featureId,
int alpha)
Convenience for calling Window.setFeatureDrawableAlpha(int, int). |
void |
setFeatureDrawableResource(int featureId,
int resId)
Convenience for calling Window.setFeatureDrawableResource(int, int). |
void |
setFeatureDrawableUri(int featureId,
Uri uri)
Convenience for calling Window.setFeatureDrawableUri(int, android.net.Uri). |
void |
setOnCancelListener(DialogInterface.OnCancelListener listener)
Set a listener to be invoked when the dialog is canceled. |
void |
setOnDismissListener(DialogInterface.OnDismissListener listener)
Set a listener to be invoked when the dialog is dismissed. |
void |
setOnKeyListener(DialogInterface.OnKeyListener onKeyListener)
Sets the callback that will be called if a key is dispatched to the dialog. |
void |
setOwnerActivity(Activity activity)
Sets the Activity that owns this dialog. |
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. |
void |
setVolumeControlStream(int streamType)
By default, this will use the owner Activity's suggested stream type. |
void |
show()
Start the dialog and display it on screen. |
void |
takeKeyEvents(boolean get)
Request that key events come to this dialog. |
void |
unregisterForContextMenu(View view)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
final Context mContext
final WindowManager mWindowManager
Window mWindow
View mDecor
protected boolean mCancelable
| Constructor Detail |
|---|
public Dialog(Context context)
context - The Context the Dialog is to run it. In particular, it
uses the window manager and theme in this context to
present its UI.
public Dialog(Context context,
int theme)
context - The Context in which the Dialog should run. In particular, it
uses the window manager and theme from this context to
present its UI.theme - A style resource describing the theme to use for the
window. See Style
and Theme Resources for more information about defining and using
styles. This theme is applied on top of the current theme in
context. If 0, the default dialog theme will be used.
@Deprecated
protected Dialog(Context context,
boolean cancelable,
Message cancelCallback)
protected Dialog(Context context,
boolean cancelable,
DialogInterface.OnCancelListener cancelListener)
| Method Detail |
|---|
public final Context getContext()
public final void setOwnerActivity(Activity activity)
activity - The Activity that owns this dialog.public final Activity getOwnerActivity()
Activity.showDialog(int) is used to show this Dialog, that
Activity will be the owner (by default). Depending on how this dialog was
created, this may return null.
public boolean isShowing()
public void show()
onStart().
public void hide()
public void dismiss()
onStop().
dismiss in interface DialogInterfacevoid dispatchOnCreate(Bundle savedInstanceState)
protected void onCreate(Bundle savedInstanceState)
Activity.onCreate(android.os.Bundle), you should initialized your dialog
in this method, including calling setContentView(int).
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.protected void onStart()
protected void onStop()
public Bundle onSaveInstanceState()
public void onRestoreInstanceState(Bundle savedInstanceState)
onSaveInstanceState(),
so be sure to call through to super when overriding unless you want to
do all restoring of state yourself.
savedInstanceState - The state of the dialog previously saved by
onSaveInstanceState().public Window getWindow()
public View getCurrentFocus()
Window.getCurrentFocus() on the
Window if this Activity to return the currently focused view.
getWindow(),
Window.getCurrentFocus()public View findViewById(int id)
onStart().
id - the identifier of the view to find
public void setContentView(int layoutResID)
layoutResID - Resource ID to be inflated.public void setContentView(View view)
view - The desired content to display.
public void setContentView(View view,
ViewGroup.LayoutParams params)
view - The desired content to display.params - Layout parameters for the view.
public void addContentView(View view,
ViewGroup.LayoutParams params)
view - The desired content to display.params - Layout parameters for the view.public void setTitle(CharSequence title)
title - The new text to display in the title.public void setTitle(int titleId)
titleId - the title's text resource identifier
public boolean onKeyDown(int keyCode,
KeyEvent event)
If the focused view didn't want this event, this method is called.
The default implementation handles KEYCODE_BACK to close the dialog.
onKeyDown in interface KeyEvent.CallbackkeyCode - The value in event.getKeyCode().event - Description of the key event.
onKeyUp(int, android.view.KeyEvent),
KeyEvent
public boolean onKeyUp(int keyCode,
KeyEvent event)
onKeyUp in interface KeyEvent.CallbackkeyCode - The value in event.getKeyCode().event - Description of the key event.
onKeyDown(int, android.view.KeyEvent),
KeyEvent
public boolean onKeyMultiple(int keyCode,
int repeatCount,
KeyEvent event)
KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle
the event).
onKeyMultiple in interface KeyEvent.CallbackkeyCode - The value in event.getKeyCode().repeatCount - Number of pairs as returned by event.getRepeatCount().event - Description of the key event.
public boolean onTouchEvent(MotionEvent event)
event - The touch screen event being processed.
public boolean onTrackballEvent(MotionEvent event)
event - The trackball event being processed.
public void onWindowAttributesChanged(WindowManager.LayoutParams params)
Window.Callback
onWindowAttributesChanged in interface Window.Callbackpublic void onContentChanged()
Window.CallbackWindow.setContentView or
Window.addContentView).
onContentChanged in interface Window.Callbackpublic void onWindowFocusChanged(boolean hasFocus)
Window.Callback
onWindowFocusChanged in interface Window.CallbackhasFocus - Whether the window now has focus.public boolean dispatchKeyEvent(KeyEvent event)
dispatchKeyEvent in interface Window.Callbackevent - The key event.
public boolean dispatchTouchEvent(MotionEvent ev)
dispatchTouchEvent in interface Window.Callbackev - The touch screen event.
public boolean dispatchTrackballEvent(MotionEvent ev)
dispatchTrackballEvent in interface Window.Callbackev - The trackball event.
public View onCreatePanelView(int featureId)
Window.Callback
onCreatePanelView in interface Window.CallbackfeatureId - Which panel is being created.
Activity.onCreatePanelView(int)
public boolean onCreatePanelMenu(int featureId,
Menu menu)
Window.CallbackYou can safely hold on to menu (and any items created from it), making modifications to it as desired, until the next time onCreatePanelMenu() is called for this feature.
onCreatePanelMenu in interface Window.CallbackfeatureId - The panel being created.menu - The menu inside the panel.
Activity.onCreatePanelMenu(int, Menu)
public boolean onPreparePanel(int featureId,
View view,
Menu menu)
Window.Callback
onPreparePanel in interface Window.CallbackfeatureId - The panel that is being displayed.view - The View that was returned by onCreatePanelView().menu - If onCreatePanelView() returned null, this is the Menu
being displayed in the panel.
Activity.onPreparePanel(int, View, Menu)
public boolean onMenuOpened(int featureId,
Menu menu)
Window.Callback
onMenuOpened in interface Window.CallbackfeatureId - The panel that the menu is in.menu - The menu that is opened.
Activity.onMenuOpened(int, Menu)
public boolean onMenuItemSelected(int featureId,
MenuItem item)
Window.Callback
onMenuItemSelected in interface Window.CallbackfeatureId - The panel that the menu is in.item - The menu item that was selected.
Activity.onMenuItemSelected(int, MenuItem)
public void onPanelClosed(int featureId,
Menu menu)
Window.Callback
onPanelClosed in interface Window.CallbackfeatureId - The panel that is being displayed.menu - If onCreatePanelView() returned null, this is the Menu
being displayed in the panel.Activity.onPanelClosed(int, Menu)public boolean onCreateOptionsMenu(Menu menu)
Activity.onCreateOptionsMenu(Menu) if the client desires the same
menu for this Dialog.
Activity.onCreateOptionsMenu(Menu),
getOwnerActivity()public boolean onPrepareOptionsMenu(Menu menu)
Activity.onPrepareOptionsMenu(Menu) if the client desires the
same menu for this Dialog.
Activity.onPrepareOptionsMenu(Menu),
getOwnerActivity()public boolean onOptionsItemSelected(MenuItem item)
Activity.onOptionsItemSelected(MenuItem)public void onOptionsMenuClosed(Menu menu)
Activity.onOptionsMenuClosed(Menu)public void openOptionsMenu()
Activity.openOptionsMenu()public void closeOptionsMenu()
Activity.closeOptionsMenu()
public void onCreateContextMenu(ContextMenu menu,
View v,
ContextMenu.ContextMenuInfo menuInfo)
View.OnCreateContextMenuListener
onCreateContextMenu in interface View.OnCreateContextMenuListenermenu - The context menu that is being builtv - The view for which the context menu is being builtmenuInfo - Extra information about the item for which the
context menu should be shown. This information will vary
depending on the class of v.Activity#onCreateContextMenu(ContextMenu, View, ContextMenuInfo)public void registerForContextMenu(View view)
Activity.registerForContextMenu(View)public void unregisterForContextMenu(View view)
Activity.unregisterForContextMenu(View)public void openContextMenu(View view)
Activity.openContextMenu(View)public boolean onContextItemSelected(MenuItem item)
Activity.onContextItemSelected(MenuItem)public void onContextMenuClosed(Menu menu)
Activity.onContextMenuClosed(Menu)public boolean onSearchRequested()
onSearchRequested in interface Window.CallbackActivity.onSearchRequested()public void takeKeyEvents(boolean get)
get - true if the dialog should receive key events, false otherwiseWindow.takeKeyEvents(boolean)public final boolean requestWindowFeature(int featureId)
getWindow().requestFeature().
featureId - The desired feature as defined in
Window.
Window.requestFeature(int)
public final void setFeatureDrawableResource(int featureId,
int resId)
Window.setFeatureDrawableResource(int, int).
public final void setFeatureDrawableUri(int featureId,
Uri uri)
Window.setFeatureDrawableUri(int, android.net.Uri).
public final void setFeatureDrawable(int featureId,
Drawable drawable)
Window.setFeatureDrawable(int, Drawable).
public final void setFeatureDrawableAlpha(int featureId,
int alpha)
Window.setFeatureDrawableAlpha(int, int).
public LayoutInflater getLayoutInflater()
public void setCancelable(boolean flag)
BACK key.
public void setCanceledOnTouchOutside(boolean cancel)
cancel - Whether the dialog should be canceled when touched outside
the window.public void cancel()
dismiss(), but it will
also call your DialogInterface.OnCancelListener (if registered).
cancel in interface DialogInterfacepublic void setOnCancelListener(DialogInterface.OnCancelListener listener)
This will only be invoked when the dialog is canceled, if the creator
needs to know when it is dismissed in general, use
setOnDismissListener(android.content.DialogInterface.OnDismissListener).
listener - The DialogInterface.OnCancelListener to use.public void setCancelMessage(Message msg)
msg - The msg to send when the dialog is canceled.setOnCancelListener(android.content.DialogInterface.OnCancelListener)public void setOnDismissListener(DialogInterface.OnDismissListener listener)
listener - The DialogInterface.OnDismissListener to use.public void setDismissMessage(Message msg)
msg - The msg to send when the dialog is dismissed.public final void setVolumeControlStream(int streamType)
Activity.setVolumeControlStream(int),
setOwnerActivity(Activity)public final int getVolumeControlStream()
Activity.getVolumeControlStream()public void setOnKeyListener(DialogInterface.OnKeyListener onKeyListener)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||