Most visited

Recently visited

RecyclerView.OnItemTouchListener

public static interface RecyclerView.OnItemTouchListener

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


OnItemTouchListener允许应用程序在RecyclerView自身的滚动行为被视为这些触摸事件之前,在RecyclerView的视图层次结构级别拦截正在进行的触摸事件。

这对于希望在RecyclerView中实现各种形式的对项目视图进行手势操纵的应用程序非常有用。 OnItemTouchListeners可以拦截已经在进行的触摸交互,即使RecyclerView已经在为了滚动的目的而处理该手势流本身。

也可以看看:

Summary

Public methods

abstract boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e)

在RecyclerView本身或其子视图处理它们之前,默认观察和/或接管发送到RecyclerView的触摸事件。

abstract void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept)

当RecyclerView的一个孩子不想让RecyclerView及其祖先用 onInterceptTouchEvent(MotionEvent)拦截触摸事件时 onInterceptTouchEvent(MotionEvent)

abstract void onTouchEvent(RecyclerView rv, MotionEvent e)

将触摸事件作为手势的一部分进行处理,该手势通过之前调用 onInterceptTouchEvent(RecyclerView, MotionEvent)返回true而被声明。

Public methods

onInterceptTouchEvent

boolean onInterceptTouchEvent (RecyclerView rv, 
                MotionEvent e)

在RecyclerView本身或其子视图处理它们之前,默认观察和/或接管发送到RecyclerView的触摸事件。

每个附加的OnItemTouchListener的onInterceptTouchEvent方法将按照RecyclerView本身或子视图进行任何其他触摸处理之前添加每个侦听器的顺序运行。

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

void onRequestDisallowInterceptTouchEvent (boolean disallowIntercept)

当RecyclerView的孩子不想让RecyclerView及其祖先用 onInterceptTouchEvent(MotionEvent)拦截触摸事件时 onInterceptTouchEvent(MotionEvent)

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

也可以看看:

onTouchEvent

void onTouchEvent (RecyclerView rv, 
                MotionEvent e)

将触摸事件作为手势的一部分进行处理,该手势通过先前调用 onInterceptTouchEvent(RecyclerView, MotionEvent)返回true onInterceptTouchEvent(RecyclerView, MotionEvent)

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

Hooray!