码迷,mamicode.com
首页 > 其他好文 > 详细

OnScrollListener

时间:2019-08-04 19:42:41      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:put   bee   用户   inpu   bsp   news   not   实现   who   

public abstract static class OnScrollListener {
/**
* Callback method to be invoked when RecyclerView‘s scroll state changes.
*
* @param recyclerView The RecyclerView whose scroll state has changed.
* @param newState The updated scroll state. One of {@link #SCROLL_STATE_IDLE},
* {@link #SCROLL_STATE_DRAGGING} or {@link #SCROLL_STATE_SETTLING}.
*/
public void onScrollStateChanged(RecyclerView recyclerView, int newState){}

/**
* Callback method to be invoked when the RecyclerView has been scrolled. This will be
* called after the scroll has completed.
* <p>
* This callback will also be called if visible item range changes after a layout
* calculation. In that case, dx and dy will be 0.
*
* @param recyclerView The RecyclerView which scrolled.
* @param dx The amount of horizontal scroll.
* @param dy The amount of vertical scroll.
*/
public void onScrolled(RecyclerView recyclerView, int dx, int dy){}
}
可见,OnScrollListenerll类是一个什么类?“abstract”,即抽象类。我们知道,子类是必须实现父类的抽象方法。其中,onScrollStateChanged  、onScrolled不是抽象方法,有自己的方法体,无需子类必须实现。

onScrolled方法3个参数:1、recyclerView 是要被监听的列表;2、x坐标滑动值;3、y坐标滑动值。

onScrollStateChanged方法2个参数:1、recyclerView 是要被监听的列表;2、newState是滑动状态。

滑动状态值如下:(抬起、滑动中)

/**
* The RecyclerView is not currently scrolling.当前未滚动。
*/
public static final int SCROLL_STATE_IDLE = 0;

/**
* The RecyclerView is currently being dragged by outside input such as user touch input.
* 目前正在被外部输入拖拽,比如用户触摸输入。
*/
public static final int SCROLL_STATE_DRAGGING = 1;
--------------------- 

OnScrollListener

标签:put   bee   用户   inpu   bsp   news   not   实现   who   

原文地址:https://www.cnblogs.com/liyanyan665/p/11299164.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!