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
从这个类。
Nested classes |
|
---|---|
interface |
RecyclerViewActions.PositionableRecyclerViewAction 大多数RecyclerViewAction都有一个匹配器,用于在RecyclerView中选择一个特定的视图/视图。 |
Public methods |
|
---|---|
static <VH extends RecyclerView.ViewHolder> RecyclerViewActions.PositionableRecyclerViewAction |
actionOnHolderItem(Matcher<VH> viewHolderMatcher, ViewAction viewAction) 执行 |
static <VH extends RecyclerView.ViewHolder> RecyclerViewActions.PositionableRecyclerViewAction |
actionOnItem(Matcher<View> itemViewMatcher, ViewAction viewAction) 执行 |
static <VH extends RecyclerView.ViewHolder> ViewAction |
actionOnItemAtPosition(int position, ViewAction viewAction) 对位置上的视图执行 |
static <VH extends RecyclerView.ViewHolder> RecyclerViewActions.PositionableRecyclerViewAction |
scrollTo(Matcher<View> itemViewMatcher) 返回一个 |
static <VH extends RecyclerView.ViewHolder> RecyclerViewActions.PositionableRecyclerViewAction |
scrollToHolder(Matcher<VH> viewHolderMatcher) 返回 |
static <VH extends RecyclerView.ViewHolder> ViewAction |
scrollToPosition(int position) 返回 |
Inherited methods |
|
---|---|
From class java.lang.Object
|
RecyclerViewActions.PositionableRecyclerViewAction actionOnHolderItem (Matcher<VH> viewHolderMatcher, ViewAction viewAction)
对 ViewAction
匹配的视图执行ViewAction。
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. |
RecyclerViewActions.PositionableRecyclerViewAction actionOnItem (Matcher<View> itemViewMatcher, ViewAction viewAction)
对 ViewAction
匹配的视图执行ViewAction。
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. |
ViewAction actionOnItemAtPosition (int position, ViewAction viewAction)
对位置上的视图执行 ViewAction
。
Parameters | |
---|---|
position |
int : position of a view in RecyclerView |
viewAction |
ViewAction : the action that is performed on the view matched by itemViewMatcher |
Returns | |
---|---|
ViewAction |
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. |
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. |
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 |