RecyclerViewActions

public final class RecyclerViewActions
extends Object

java.lang.Object
   ↳ android.support.test.espresso.contrib.RecyclerViewActions


ViewAction s进行交互RecyclerView RecyclerView的工作方式与AdapterView不同。 事实上,RecyclerView不再是AdapterView,因此它不能与onData(Matcher)组合使用。

要使用 ViewAction在这个类使用s onView(Matcher)Matcher ,你的匹配 RecyclerView ,然后执行 ViewAction从这个类。

Summary

Nested classes

interface RecyclerViewActions.PositionableRecyclerViewAction

大多数RecyclerViewAction都有一个匹配器,用于在RecyclerView中选择一个特定的视图/视图。

Public methods

static <VH extends RecyclerView.ViewHolder> RecyclerViewActions.PositionableRecyclerViewAction actionOnHolderItem(Matcher<VH> viewHolderMatcher, ViewAction viewAction)

执行 ViewAction由viewHolderMatcher匹配的图。

static <VH extends RecyclerView.ViewHolder> RecyclerViewActions.PositionableRecyclerViewAction actionOnItem(Matcher<View> itemViewMatcher, ViewAction viewAction)

执行 ViewAction由viewHolderMatcher匹配的图。

static <VH extends RecyclerView.ViewHolder> ViewAction actionOnItemAtPosition(int position, ViewAction viewAction)

对位置上的视图执行 ViewAction

static <VH extends RecyclerView.ViewHolder> RecyclerViewActions.PositionableRecyclerViewAction scrollTo(Matcher<View> itemViewMatcher)

返回一个 ViewAction ,将 ViewAction滚动到 RecyclerView所匹配的视图。

static <VH extends RecyclerView.ViewHolder> RecyclerViewActions.PositionableRecyclerViewAction scrollToHolder(Matcher<VH> viewHolderMatcher)

返回 ViewAction其滚动 RecyclerView由viewHolderMatcher匹配视图。

static <VH extends RecyclerView.ViewHolder> ViewAction scrollToPosition(int position)

返回 ViewAction其滚动 RecyclerView的位置。

Inherited methods

From class java.lang.Object

Public methods

actionOnHolderItem

RecyclerViewActions.PositionableRecyclerViewAction actionOnHolderItem (Matcher<VH> viewHolderMatcher, 
                ViewAction viewAction)

ViewAction匹配的视图执行ViewAction

  1. Scroll Recycler View to the view matched by itemViewMatcher
  2. Perform an action on the matched view
Note: actionOnItem method is not overloaded, method overloading with generic parameters is not possible.

Parameters
viewHolderMatcher Matcher: a Matcher that matchesan item view holder in RecyclerView
viewAction ViewAction: the action that is performed on the view matched by viewHolderMatcher
Returns
RecyclerViewActions.PositionableRecyclerViewAction
Throws
PerformException if there are more than one items matching given viewHolderMatcher.

actionOnItem

RecyclerViewActions.PositionableRecyclerViewAction actionOnItem (Matcher<View> itemViewMatcher, 
                ViewAction viewAction)

ViewAction匹配的视图执行ViewAction

  1. Scroll Recycler View to the view matched by itemViewMatcher
  2. Perform an action on the matched view

Parameters
itemViewMatcher Matcher: a Matcher that matches an item view in RecyclerView
viewAction ViewAction: the action that is performed on the view matched by itemViewMatcher
Returns
RecyclerViewActions.PositionableRecyclerViewAction
Throws
PerformException if there are more than one items matching given viewHolderMatcher.

actionOnItemAtPosition

ViewAction actionOnItemAtPosition (int position, 
                ViewAction viewAction)

对位置上的视图执行 ViewAction

  1. Scroll Recycler View to position
  2. Perform an action on the view at position

Parameters
position int: position of a view in RecyclerView
viewAction ViewAction: the action that is performed on the view matched by itemViewMatcher
Returns
ViewAction

scrollTo

RecyclerViewActions.PositionableRecyclerViewAction scrollTo (Matcher<View> itemViewMatcher)

返回 ViewAction ,将 ViewAction滚动到 RecyclerView所匹配的视图。

该方法使用RecyclerView.ViewHolder来查找目标视图。 它将为每个项目类型创建一个ViewHolder并将适配器数据绑定到ViewHolder。 如果itemViewMatcher与ViewHolder匹配,则视图的当前位置用于执行scrollToPosition(int)

Parameters
itemViewMatcher Matcher: a Matcher that matches an item view in RecyclerView
Returns
RecyclerViewActions.PositionableRecyclerViewAction
Throws
PerformException if there are more than one items matching given viewHolderMatcher.

scrollToHolder

RecyclerViewActions.PositionableRecyclerViewAction scrollToHolder (Matcher<VH> viewHolderMatcher)

返回 ViewAction其滚动 RecyclerView由viewHolderMatcher匹配视图。

该方法使用RecyclerView.ViewHolder来查找目标视图。 它将为每个项目类型创建一个ViewHolder并将适配器数据绑定到ViewHolder。 如果itemViewMatcher与ViewHolder匹配,则视图的当前位置用于执行scrollToPosition(int) 注意:scrollTo方法不会重载,使用泛型参数的方法重载是不可能的。

Parameters
viewHolderMatcher Matcher: a Matcher that matches an item view holder in RecyclerView
Returns
RecyclerViewActions.PositionableRecyclerViewAction
Throws
PerformException if there are more than one items matching given viewHolderMatcher.

scrollToPosition

ViewAction scrollToPosition (int position)

Returns a ViewAction which scrolls RecyclerView to a position.

Parameters
position int: the position of the view to scroll to
Returns
ViewAction