com.xtremelabs.robolectric.shadows
Class ShadowAlertDialog

java.lang.Object
  extended by com.xtremelabs.robolectric.shadows.ShadowDialog
      extended by com.xtremelabs.robolectric.shadows.ShadowAlertDialog

@Implements(value=android.app.AlertDialog.class)
public class ShadowAlertDialog
extends ShadowDialog


Nested Class Summary
static class ShadowAlertDialog.ShadowBuilder
          Shadows the android.app.AlertDialog.Builder class.
 
Constructor Summary
ShadowAlertDialog()
           
 
Method Summary
 void clickOnItem(int index)
          Simulates a click on the Dialog item indicated by index.
 android.view.View findViewById(int viewId)
           
 android.widget.Button getButton(int whichButton)
           
 boolean[] getCheckedItems()
          Non-Android accessor.
 java.lang.CharSequence[] getItems()
          Non-Android accessor.
static ShadowAlertDialog getLatestAlertDialog()
          Non-Android accessor.
 java.lang.String getMessage()
          Non-Android accessor.
 java.lang.String getTitle()
          Non-Android accessor.
static void reset()
          Resets the tracking of the most recently created AlertDialog
 
Methods inherited from class com.xtremelabs.robolectric.shadows.ShadowDialog
__constructor__, __constructor__, cancel, clickOn, dismiss, getContext, getLatestDialog, getLayoutId, getOwnerActivity, getThemeId, getWindow, hasBeenDismissed, hide, isShowing, setContentView, setOnCancelListener, setOnDismissListener, setOwnerActivity, setTitle, setTitle, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShadowAlertDialog

public ShadowAlertDialog()
Method Detail

getLatestAlertDialog

public static ShadowAlertDialog getLatestAlertDialog()
Non-Android accessor.

Returns:
the most recently created AlertDialog, or null if none has been created during this test run

findViewById

@Implementation
public android.view.View findViewById(int viewId)
Overrides:
findViewById in class ShadowDialog

reset

public static void reset()
Resets the tracking of the most recently created AlertDialog


clickOnItem

public void clickOnItem(int index)
Simulates a click on the Dialog item indicated by index. Handles both multi- and single-choice dialogs, tracks which items are currently checked and calls listeners appropriately.

Parameters:
index - the index of the item to click on

getButton

@Implementation
public android.widget.Button getButton(int whichButton)

getItems

public java.lang.CharSequence[] getItems()
Non-Android accessor.

Returns:
the items that are available to be clicked on

getTitle

public java.lang.String getTitle()
Non-Android accessor.

Overrides:
getTitle in class ShadowDialog
Returns:
the title of the dialog

getMessage

public java.lang.String getMessage()
Non-Android accessor.

Returns:
the message displayed in the dialog

getCheckedItems

public boolean[] getCheckedItems()
Non-Android accessor.

Returns:
an array indicating which items are and are not clicked on a multi-choice dialog todo: support single choice dialogs