Most RecyclerViewActions are given a matcher to select a particular view / viewholder within
the RecyclerView. In this case the default behaviour is to expect that the matcher matches 1
and only one item within the RecyclerView.
This interface gives users the ability to override that type of behaviour and explicitly
select an item in the RecyclerView at a given position. This is similar to on the
onData(...).atPosition() api for AdapterViews.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# RecyclerViewActions.PositionableRecyclerViewAction\n\nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nRecyclerViewActions.PositionableRecyclerViewAction\n==================================================\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\nstatic\n\n\ninterface\nRecyclerViewActions.PositionableRecyclerViewAction\n`\n\n\n`\n\n\nimplements\n\n`[ViewAction](/reference/android/support/test/espresso/ViewAction)`\n\n\n`\n\n|------------------------------------------------------------------------------------------|\n| android.support.test.espresso.contrib.RecyclerViewActions.PositionableRecyclerViewAction |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nMost RecyclerViewActions are given a matcher to select a particular view / viewholder within\nthe RecyclerView. In this case the default behaviour is to expect that the matcher matches 1\nand only one item within the RecyclerView.\n\nThis interface gives users the ability to override that type of behaviour and explicitly\nselect an item in the RecyclerView at a given position. This is similar to on the\nonData(...).atPosition() api for AdapterViews.\n\nSummary\n-------\n\n| ### Public methods ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract `[RecyclerViewActions.PositionableRecyclerViewAction](/reference/android/support/test/espresso/contrib/RecyclerViewActions.PositionableRecyclerViewAction) | ` `[atPosition](/reference/android/support/test/espresso/contrib/RecyclerViewActions.PositionableRecyclerViewAction#atPosition(int))`(int position) ` Returns a new ViewAction which will cause the ViewAction to operate upon the position-th element which the matcher has selected. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[android.support.test.espresso.ViewAction](/reference/android/support/test/espresso/ViewAction)` ` |-----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract Matcher\u003c`[View](https://developer.android.com/reference/android/view/View.html)`\u003e` | ` `[getConstraints](/reference/android/support/test/espresso/ViewAction#getConstraints())`() ` A mechanism for ViewActions to specify what type of views they can operate on. | | ` abstract `[String](https://developer.android.com/reference/java/lang/String.html) | ` `[getDescription](/reference/android/support/test/espresso/ViewAction#getDescription())`() ` Returns a description of the view action. | | ` abstract void` | ` `[perform](/reference/android/support/test/espresso/ViewAction#perform(android.support.test.espresso.UiController, android.view.View))`(`[UiController](/reference/android/support/test/espresso/UiController)` uiController, `[View](https://developer.android.com/reference/android/view/View.html)` view) ` Performs this action on the given view. | ||\n\nPublic methods\n--------------\n\n### atPosition\n\n```\nRecyclerViewActions.PositionableRecyclerViewAction atPosition (int position)\n```\n\nReturns a new ViewAction which will cause the ViewAction to operate upon the position-th\nelement which the matcher has selected.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-------------------------------------------------------------------------------------------|\n| `position` | `int`: a 0-based index into the list of matching elements within the RecyclerView. \u003cbr /\u003e |\n\n| Returns ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|\n| [RecyclerViewActions.PositionableRecyclerViewAction](/reference/android/support/test/espresso/contrib/RecyclerViewActions.PositionableRecyclerViewAction) | PositionableRecyclerViewAction a new ViewAction focused on a particular position. \u003cbr /\u003e |\n\n| Throws ||\n|-------------------------------------------------------------------------------------------------------------|-------------------|\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if position \\\u003c 0. |\n\n-\n\n Interfaces\n ----------\n\n - [RecyclerViewActions.PositionableRecyclerViewAction](/reference/android/support/test/espresso/contrib/RecyclerViewActions.PositionableRecyclerViewAction)\n-\n\n Classes\n -------\n\n - [AccessibilityChecks](/reference/android/support/test/espresso/contrib/AccessibilityChecks)\n - [ActivityResultMatchers](/reference/android/support/test/espresso/contrib/ActivityResultMatchers)\n - [DrawerActions](/reference/android/support/test/espresso/contrib/DrawerActions)\n - [DrawerMatchers](/reference/android/support/test/espresso/contrib/DrawerMatchers)\n - [NavigationViewActions](/reference/android/support/test/espresso/contrib/NavigationViewActions)\n - [PickerActions](/reference/android/support/test/espresso/contrib/PickerActions)\n - [RecyclerViewActions](/reference/android/support/test/espresso/contrib/RecyclerViewActions)\n - [ViewPagerActions](/reference/android/support/test/espresso/contrib/ViewPagerActions)"]]