当前位置: 代码迷 >> 综合 >> ViewPager的 OnPagechangerListener的三个回调
  详细解决方案

ViewPager的 OnPagechangerListener的三个回调

热度:65   发布时间:2024-01-21 15:45:49.0


myViewPager.setOnPageChangeListener(new OnPageChangeListener() {
054
             
055
            @Override
056
            public void onPageSelected(int arg0) {
057
                Log.d("k", "onPageSelected - " + arg0);
058
                //activity从1到2滑动,2被加载后掉用此方法
059
               
062
            }
063
             
064
            @Override
065
            public void onPageScrolled(int arg0, float arg1, int arg2) {
066
                Log.d("k", "onPageScrolled - " + arg0);
067
                //从1到2滑动,在1滑动前调用//arg1:滑动轨迹x 占屏幕的的比列 arg2 滑动轨迹大长度
068
            }
069
             
070
            @Override
071
            public void onPageScrollStateChanged(int arg0) {
072
                Log.d("k", "onPageScrollStateChanged - " + arg0);
073
                //状态有三个0空闲,1是增在滑行中,2目标加载完毕
074
                /**
075
                 * Indicates that the pager is in an idle, settled state. The current page
076
                 * is fully in view and no animation is in progress.
077
                 */
078
                //public static final int SCROLL_STATE_IDLE = 0;
079
                /**
080
                 * Indicates that the pager is currently being dragged by the user.
081
                 */
082
                //public static final int SCROLL_STATE_DRAGGING = 1;
083
                /**
084
                 * Indicates that the pager is in the process of settling to a final position.
085
                 */
086
                //public static final int SCROLL_STATE_SETTLING = 2;
087


088
            }
089
        });
  相关解决方案