Class ShadowAlertDialog

java.lang.Object
org.robolectric.shadows.ShadowDialog
org.robolectric.shadows.ShadowAlertDialog
Direct Known Subclasses:
ShadowDatePickerDialog, ShadowProgressDialog, ShadowTimePickerDialog

@Implements(android.app.AlertDialog.class) public class ShadowAlertDialog extends ShadowDialog
  • Constructor Details

    • ShadowAlertDialog

      public ShadowAlertDialog()
  • Method Details

    • getLatestAlertDialog

      public static AlertDialog getLatestAlertDialog()
      Returns:
      the most recently created AlertDialog, or null if none has been created during this test run
    • getCustomView

      public FrameLayout getCustomView()
    • reset

      @Resetter 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
    • getTitle

      public CharSequence getTitle()
      Overrides:
      getTitle in class ShadowDialog
    • getItems

      public CharSequence[] getItems()
      Returns:
      the items that are available to be clicked on
    • getAdapter

      public Adapter getAdapter()
    • getMessage

      public CharSequence getMessage()
      Returns:
      the message displayed in the dialog
    • show

      public void show()
      Overrides:
      show in class ShadowDialog
    • getView

      public View getView()
      Returns:
      the view set with AlertDialog.Builder.setView(View)
    • getIconId

      public int getIconId()
      Returns:
      the icon set with AlertDialog.Builder.setIcon(int)
    • getCustomTitleView

      public View getCustomTitleView()
      Returns:
      return the view set with AlertDialog.Builder.setCustomTitle(View)