RecyclerViewActions
  public
  
  final
  
  class
  RecyclerViewActions
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.support.test.espresso.contrib.RecyclerViewActions | 
ViewActions to interact RecyclerView. RecyclerView works differently than AdapterView. In fact, RecyclerView is not an AdapterView anymore, hence it can't be used in
 combination with onData(Matcher).
 
To use ViewActions in this class use onView(Matcher) with a Matcher
  that matches your RecyclerView, then perform a ViewAction from this
 class.
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        interface | RecyclerViewActions.PositionableRecyclerViewActionMost RecyclerViewActions are given a matcher to select a particular view / viewholder within the RecyclerView. | 
| Public methods | |
|---|---|
| 
        
        
        static
        
        <VH extends RecyclerView.ViewHolder>
        RecyclerViewActions.PositionableRecyclerViewAction | 
      actionOnHolderItem(Matcher<VH> viewHolderMatcher, ViewAction viewAction)
      Performs a  | 
| 
        
        
        static
        
        <VH extends RecyclerView.ViewHolder>
        RecyclerViewActions.PositionableRecyclerViewAction | 
      actionOnItem(Matcher<View> itemViewMatcher, ViewAction viewAction)
      Performs a  | 
| 
        
        
        static
        
        <VH extends RecyclerView.ViewHolder>
        ViewAction | 
      actionOnItemAtPosition(int position, ViewAction viewAction)
      Performs a  | 
| 
        
        
        static
        
        <VH extends RecyclerView.ViewHolder>
        RecyclerViewActions.PositionableRecyclerViewAction | 
      scrollTo(Matcher<View> itemViewMatcher)
      Returns a  | 
| 
        
        
        static
        
        <VH extends RecyclerView.ViewHolder>
        RecyclerViewActions.PositionableRecyclerViewAction | 
      scrollToHolder(Matcher<VH> viewHolderMatcher)
      Returns a  | 
| 
        
        
        static
        
        <VH extends RecyclerView.ViewHolder>
        ViewAction | 
      scrollToPosition(int position)
      Returns a  | 
| Inherited methods | |
|---|---|
|  From
class 
  
    java.lang.Object
  
 | |
Public methods
actionOnHolderItem
RecyclerViewActions.PositionableRecyclerViewAction actionOnHolderItem (Matcher<VH> viewHolderMatcher, ViewAction viewAction)
Performs a ViewAction on a view matched by viewHolderMatcher.
 
- Scroll Recycler View to the view matched by itemViewMatcher
- Perform an action on the matched view
| Parameters | |
|---|---|
| viewHolderMatcher | Matcher: aMatcher
     that matches an item view holder inRecyclerView | 
| 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)
Performs a ViewAction on a view matched by viewHolderMatcher.
 
- Scroll Recycler View to the view matched by itemViewMatcher
- Perform an action on the matched view
| Parameters | |
|---|---|
| itemViewMatcher | Matcher: aMatcher
     that matches an item view inRecyclerView | 
| 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)
Performs a ViewAction on a view at position.
 
- Scroll Recycler View to position
- Perform an action on the view at position
| Parameters | |
|---|---|
| position | int: position of a view inRecyclerView | 
| viewAction | ViewAction: the action that is performed on the view matched by itemViewMatcher | 
| Returns | |
|---|---|
| ViewAction | |
scrollTo
RecyclerViewActions.PositionableRecyclerViewAction scrollTo (Matcher<View> itemViewMatcher)
Returns a ViewAction which scrolls RecyclerView to the view matched by
 itemViewMatcher.
 
This approach uses RecyclerView.ViewHolders to find the target view. It will create one
 ViewHolder per item type and bind adapter data to the ViewHolder. If the itemViewMatcher
 matches a ViewHolder the current position of the View is used to perform a scrollToPosition(int).
| Parameters | |
|---|---|
| itemViewMatcher | Matcher: aMatcher
     that matches an item view inRecyclerView | 
| Returns | |
|---|---|
| RecyclerViewActions.PositionableRecyclerViewAction | |
| Throws | |
|---|---|
| PerformException | if there are more than one items matching given viewHolderMatcher. | 
scrollToHolder
RecyclerViewActions.PositionableRecyclerViewAction scrollToHolder (Matcher<VH> viewHolderMatcher)
Returns a ViewAction which scrolls RecyclerView to the view matched by
 viewHolderMatcher.
 
This approach uses RecyclerView.ViewHolders to find the target view. It will create one
 ViewHolder per item type and bind adapter data to the ViewHolder. If the itemViewMatcher
 matches a ViewHolder the current position of the View is used to perform a scrollToPosition(int). Note: scrollTo method is not overloaded, method
 overloading with generic parameters is not possible.
| Parameters | |
|---|---|
| viewHolderMatcher | Matcher: aMatcher
     that matches an item view holder inRecyclerView | 
| 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 | |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
