public static boolean clickListViewItem(ListView listView, int position) {
    try {
      // Here we assume that accidental long-press can usually be undone by pressing back
      onView(is(listView.getChildAt(position))).perform(click(pressBack()));
      return true;
    } catch (Exception e) {
      return false;
    }
  }
Performs a click/tap on a list item at the specified position.

@return {@code true} if the click/tap was consumed, {@code false} otherwise.
javatests/com/google/android/apps/authenticator/testing/TestUtilities.java