Skip to content

Most visited

Recently visited

navigation
added in version 22.0.0

RecyclerView.OnItemTouchListener

public static interface RecyclerView.OnItemTouchListener

android.support.v7.widget.RecyclerView.OnItemTouchListener
Known Indirect Subclasses


An OnItemTouchListener allows the application to intercept touch events in progress at the view hierarchy level of the RecyclerView before those touch events are considered for RecyclerView's own scrolling behavior.

This can be useful for applications that wish to implement various forms of gestural manipulation of item views within the RecyclerView. OnItemTouchListeners may intercept a touch interaction already in progress even if the RecyclerView is already handling that gesture stream itself for the purposes of scrolling.

See also:

Summary

Public methods

abstract boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e)

Silently observe and/or take over touch events sent to the RecyclerView before they are handled by either the RecyclerView itself or its child views.

abstract void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept)

Called when a child of RecyclerView does not want RecyclerView and its ancestors to intercept touch events with onInterceptTouchEvent(MotionEvent).

abstract void onTouchEvent(RecyclerView rv, MotionEvent e)

Process a touch event as part of a gesture that was claimed by returning true from a previous call to onInterceptTouchEvent(RecyclerView, MotionEvent).

Public methods

onInterceptTouchEvent

added in version 22.0.0
boolean onInterceptTouchEvent (RecyclerView rv, 
                MotionEvent e)

Silently observe and/or take over touch events sent to the RecyclerView before they are handled by either the RecyclerView itself or its child views.

The onInterceptTouchEvent methods of each attached OnItemTouchListener will be run in the order in which each listener was added, before any other touch processing by the RecyclerView itself or child views occurs.

Parameters
rv RecyclerView

e MotionEvent: MotionEvent describing the touch event. All coordinates are in the RecyclerView's coordinate system.

Returns
boolean true if this OnItemTouchListener wishes to begin intercepting touch events, false to continue with the current behavior and continue observing future events in the gesture.

onRequestDisallowInterceptTouchEvent

added in version 22.2.0
void onRequestDisallowInterceptTouchEvent (boolean disallowIntercept)

Called when a child of RecyclerView does not want RecyclerView and its ancestors to intercept touch events with onInterceptTouchEvent(MotionEvent).

Parameters
disallowIntercept boolean: True if the child does not want the parent to intercept touch events.

See also:

onTouchEvent

added in version 22.0.0
void onTouchEvent (RecyclerView rv, 
                MotionEvent e)

Process a touch event as part of a gesture that was claimed by returning true from a previous call to onInterceptTouchEvent(RecyclerView, MotionEvent).

Parameters
rv RecyclerView

e MotionEvent: MotionEvent describing the touch event. All coordinates are in the RecyclerView's coordinate system.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)