|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.app.Dialog
android.app.AlertDialog
public class 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 "body" and add your view to it:
FrameLayout fl = (FrameLayout) findViewById(R.id.body); fl.add(myView, new LayoutParams(FILL_PARENT, WRAP_CONTENT));
The AlertDialog class takes care of automatically setting
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(android.os.Bundle).
| 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 |
|---|
BUTTON_NEGATIVE, BUTTON_NEUTRAL, BUTTON_POSITIVE, 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 | |
|---|---|
Button |
getButton(int whichButton)
Gets one of the buttons used in the dialog. |
ListView |
getListView()
Gets the list view used in the dialog. |
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)
Deprecated. Use setButton(int, CharSequence, android.content.DialogInterface.OnClickListener)
with DialogInterface.BUTTON_POSITIVE |
void |
setButton(CharSequence text,
Message msg)
Deprecated. Use setButton(int, CharSequence, Message) with
DialogInterface.BUTTON_POSITIVE. |
void |
setButton(int whichButton,
CharSequence text,
DialogInterface.OnClickListener listener)
Set a listener to be invoked when the positive button of the dialog is pressed. |
void |
setButton(int whichButton,
CharSequence text,
Message msg)
Set a message to be sent when a button is pressed. |
void |
setButton2(CharSequence text,
DialogInterface.OnClickListener listener)
Deprecated. Use setButton(int, CharSequence, android.content.DialogInterface.OnClickListener)
with DialogInterface.BUTTON_NEGATIVE |
void |
setButton2(CharSequence text,
Message msg)
Deprecated. Use setButton(int, CharSequence, Message) with
DialogInterface.BUTTON_NEGATIVE. |
void |
setButton3(CharSequence text,
DialogInterface.OnClickListener listener)
Deprecated. Use setButton(int, CharSequence, android.content.DialogInterface.OnClickListener)
with DialogInterface.BUTTON_POSITIVE |
void |
setButton3(CharSequence text,
Message msg)
Deprecated. Use setButton(int, CharSequence, Message) with
DialogInterface.BUTTON_NEUTRAL. |
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. |
void |
setView(View view,
int viewSpacingLeft,
int viewSpacingTop,
int viewSpacingRight,
int viewSpacingBottom)
Set the view to display in that dialog, specifying the spacing to appear around that view. |
| 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 |
|---|
protected AlertDialog(Context context)
protected AlertDialog(Context context,
int theme)
protected AlertDialog(Context context,
boolean cancelable,
DialogInterface.OnCancelListener cancelListener)
| Method Detail |
|---|
public Button getButton(int whichButton)
If a button does not exist in the dialog, null will be returned.
whichButton - The identifier of the button that should be returned.
For example, this can be
DialogInterface.BUTTON_POSITIVE.
public ListView getListView()
ListView from the dialog.public void setTitle(CharSequence title)
Dialog
setTitle in class Dialogtitle - The new text to display in the title.public void setCustomTitle(View customTitleView)
AlertDialog.Builder.setCustomTitle(View)public void setMessage(CharSequence message)
public void setView(View view)
public void setView(View view,
int viewSpacingLeft,
int viewSpacingTop,
int viewSpacingRight,
int viewSpacingBottom)
view - The view to show in the content area of the dialogviewSpacingLeft - Extra space to appear to the left of viewviewSpacingTop - Extra space to appear above viewviewSpacingRight - Extra space to appear to the right of viewviewSpacingBottom - Extra space to appear below view
public void setButton(int whichButton,
CharSequence text,
Message msg)
whichButton - Which button to set the message for, can be one of
DialogInterface.BUTTON_POSITIVE,
DialogInterface.BUTTON_NEGATIVE, or
DialogInterface.BUTTON_NEUTRALtext - The text to display in positive button.msg - The Message to be sent when clicked.
public void setButton(int whichButton,
CharSequence text,
DialogInterface.OnClickListener listener)
whichButton - Which button to set the listener on, can be one of
DialogInterface.BUTTON_POSITIVE,
DialogInterface.BUTTON_NEGATIVE, or
DialogInterface.BUTTON_NEUTRALtext - The text to display in positive button.listener - The DialogInterface.OnClickListener to use.
@Deprecated
public void setButton(CharSequence text,
Message msg)
setButton(int, CharSequence, Message) with
DialogInterface.BUTTON_POSITIVE.
@Deprecated
public void setButton2(CharSequence text,
Message msg)
setButton(int, CharSequence, Message) with
DialogInterface.BUTTON_NEGATIVE.
@Deprecated
public void setButton3(CharSequence text,
Message msg)
setButton(int, CharSequence, Message) with
DialogInterface.BUTTON_NEUTRAL.
@Deprecated
public void setButton(CharSequence text,
DialogInterface.OnClickListener listener)
setButton(int, CharSequence, android.content.DialogInterface.OnClickListener)
with DialogInterface.BUTTON_POSITIVE
text - The text to display in button 1.listener - The DialogInterface.OnClickListener to use.
@Deprecated
public void setButton2(CharSequence text,
DialogInterface.OnClickListener listener)
setButton(int, CharSequence, android.content.DialogInterface.OnClickListener)
with DialogInterface.BUTTON_NEGATIVE
text - The text to display in button 2.listener - The DialogInterface.OnClickListener to use.
@Deprecated
public void setButton3(CharSequence text,
DialogInterface.OnClickListener listener)
setButton(int, CharSequence, android.content.DialogInterface.OnClickListener)
with DialogInterface.BUTTON_POSITIVE
text - The text to display in button 3.listener - The DialogInterface.OnClickListener to use.public void setIcon(int resId)
resId - the resourceId of the drawable to use as the icon or 0
if you don't want an icon.public void setIcon(Drawable icon)
public void setInverseBackgroundForced(boolean forceInverseBackground)
protected void onCreate(Bundle savedInstanceState)
DialogActivity.onCreate(android.os.Bundle), you should initialized your dialog
in this method, including calling Dialog.setContentView(int).
onCreate in class DialogsavedInstanceState - 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.
public boolean onKeyDown(int keyCode,
KeyEvent event)
DialogIf 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.CallbackonKeyDown in class DialogkeyCode - The value in event.getKeyCode().event - Description of the key event.
Dialog.onKeyUp(int, android.view.KeyEvent),
KeyEvent
public boolean onKeyUp(int keyCode,
KeyEvent event)
Dialog
onKeyUp in interface KeyEvent.CallbackonKeyUp in class DialogkeyCode - The value in event.getKeyCode().event - Description of the key event.
Dialog.onKeyDown(int, android.view.KeyEvent),
KeyEvent
|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||