Build 1.0_r1(from source)

android.app
Class AlertDialog

java.lang.Object
  extended by android.app.Dialog
      extended by android.app.AlertDialog
All Implemented Interfaces:
DialogInterface, KeyEvent.Callback, View.OnCreateContextMenuListener, Window.Callback
Direct Known Subclasses:
DatePickerDialog, ProgressDialog, TimePickerDialog

public class AlertDialog
extends Dialog
implements DialogInterface

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 "body" and add your view to it:

 FrameLayout fl = (FrameLayout) findViewById(R.id.body);
 fl.add(myView, new LayoutParams(FILL_PARENT, WRAP_CONTENT));
 


Nested Class Summary
static class AlertDialog.Builder
           
 
Nested classes/interfaces inherited from interface android.content.DialogInterface
DialogInterface.OnCancelListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, DialogInterface.OnKeyListener, DialogInterface.OnMultiChoiceClickListener
 
Field Summary
 
Fields inherited from class android.app.Dialog
mCancelable, mContext, mDecor, mWindow, mWindowManager
 
Fields inherited from interface android.content.DialogInterface
BUTTON1, BUTTON2, BUTTON3
 
Constructor Summary
protected AlertDialog(Context context)
           
protected AlertDialog(Context context, boolean cancelable, DialogInterface.OnCancelListener cancelListener)
           
protected AlertDialog(Context context, int theme)
           
 
Method Summary
protected  void onCreate(Bundle savedInstanceState)
          Similar to Activity.onCreate(android.os.Bundle), you should initialized your dialog in this method, including calling Dialog.setContentView(int).
 boolean onKeyDown(int keyCode, KeyEvent event)
          A key was pressed down.
 boolean onKeyUp(int keyCode, KeyEvent event)
          A key was released.
 void setButton(CharSequence text, DialogInterface.OnClickListener listener)
          Set a listener to be invoked when button 1 of the dialog is pressed.
 void setButton(CharSequence text, Message msg)
           
 void setButton2(CharSequence text, DialogInterface.OnClickListener listener)
          Set a listener to be invoked when button 2 of the dialog is pressed.
 void setButton2(CharSequence text, Message msg)
           
 void setButton3(CharSequence text, DialogInterface.OnClickListener listener)
          Set a listener to be invoked when button 3 of the dialog is pressed.
 void setButton3(CharSequence text, Message msg)
           
 void setCustomTitle(View customTitleView)
           
 void setIcon(Drawable icon)
           
 void setIcon(int resId)
          Set resId to 0 if you don't want an icon.
 void setInverseBackgroundForced(boolean forceInverseBackground)
           
 void setMessage(CharSequence message)
           
 void setTitle(CharSequence title)
          Set the title text for this dialog's window.
 void setView(View view)
          Set the view to display in that dialog.
 
Methods inherited from class android.app.Dialog
addContentView, cancel, closeOptionsMenu, dismiss, dispatchKeyEvent, dispatchOnCreate, dispatchTouchEvent, dispatchTrackballEvent, findViewById, getContext, getCurrentFocus, getLayoutInflater, getOwnerActivity, getVolumeControlStream, getWindow, hide, isShowing, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onKeyMultiple, onMenuItemSelected, onMenuOpened, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPrepareOptionsMenu, onPreparePanel, onRestoreInstanceState, onSaveInstanceState, onSearchRequested, onStart, onStop, onTouchEvent, onTrackballEvent, onWindowAttributesChanged, onWindowFocusChanged, openContextMenu, openOptionsMenu, registerForContextMenu, requestWindowFeature, setCancelable, setCanceledOnTouchOutside, setCancelMessage, setContentView, setContentView, setContentView, setDismissMessage, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setOnCancelListener, setOnDismissListener, setOnKeyListener, setOwnerActivity, setTitle, setVolumeControlStream, show, takeKeyEvents, unregisterForContextMenu
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.content.DialogInterface
cancel, dismiss
 

Constructor Detail

AlertDialog

protected AlertDialog(Context context)

AlertDialog

protected AlertDialog(Context context,
                      int theme)

AlertDialog

protected AlertDialog(Context context,
                      boolean cancelable,
                      DialogInterface.OnCancelListener cancelListener)
Method Detail

setTitle

public void setTitle(CharSequence title)
Description copied from class: Dialog
Set the title text for this dialog's window.

Overrides:
setTitle in class Dialog
Parameters:
title - The new text to display in the title.

setCustomTitle

public void setCustomTitle(View customTitleView)
See Also:
AlertDialog.Builder.setCustomTitle(View)

setMessage

public void setMessage(CharSequence message)

setView

public void setView(View view)
Set the view to display in that dialog.


setButton

public void setButton(CharSequence text,
                      Message msg)

setButton2

public void setButton2(CharSequence text,
                       Message msg)

setButton3

public void setButton3(CharSequence text,
                       Message msg)

setButton

public void setButton(CharSequence text,
                      DialogInterface.OnClickListener listener)
Set a listener to be invoked when button 1 of the dialog is pressed.

Parameters:
text - The text to display in button 1.
listener - The DialogInterface.OnClickListener to use.

setButton2

public void setButton2(CharSequence text,
                       DialogInterface.OnClickListener listener)
Set a listener to be invoked when button 2 of the dialog is pressed.

Parameters:
text - The text to display in button 2.
listener - The DialogInterface.OnClickListener to use.

setButton3

public void setButton3(CharSequence text,
                       DialogInterface.OnClickListener listener)
Set a listener to be invoked when button 3 of the dialog is pressed.

Parameters:
text - The text to display in button 3.
listener - The DialogInterface.OnClickListener to use.

setIcon

public void setIcon(int resId)
Set resId to 0 if you don't want an icon.

Parameters:
resId - the resourceId of the drawable to use as the icon or 0 if you don't want an icon.

setIcon

public void setIcon(Drawable icon)

setInverseBackgroundForced

public void setInverseBackgroundForced(boolean forceInverseBackground)

onCreate

protected void onCreate(Bundle savedInstanceState)
Description copied from class: Dialog
Similar to Activity.onCreate(android.os.Bundle), you should initialized your dialog in this method, including calling Dialog.setContentView(int).

Overrides:
onCreate in class Dialog
Parameters:
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 Dialog.onSaveInstanceState(), or null if this is the first time.

onKeyDown

public boolean onKeyDown(int keyCode,
                         KeyEvent event)
Description copied from class: Dialog
A key was pressed down.

If the focused view didn't want this event, this method is called.

The default implementation handles KEYCODE_BACK to close the dialog.

Specified by:
onKeyDown in interface KeyEvent.Callback
Overrides:
onKeyDown in class Dialog
Parameters:
keyCode - The value in event.getKeyCode().
event - Description of the key event.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
See Also:
Dialog.onKeyUp(int, android.view.KeyEvent), KeyEvent

onKeyUp

public boolean onKeyUp(int keyCode,
                       KeyEvent event)
Description copied from class: Dialog
A key was released.

Specified by:
onKeyUp in interface KeyEvent.Callback
Overrides:
onKeyUp in class Dialog
Parameters:
keyCode - The value in event.getKeyCode().
event - Description of the key event.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
See Also:
Dialog.onKeyDown(int, android.view.KeyEvent), KeyEvent

Build 1.0_r1(from source)

Please submit a feedback, bug or feature