Indicate after swiping the last page in ViewPager

☆樱花仙子☆ 提交于 2019-12-04 13:02:51

This is automatic. The OS has built in indicators to tell the user the views can't be swiped any further. The OS will display a glow on the side of the screen, and the user can't pull further.

Not sure if you can create your own unique UI to handle this - the OS does provide a indicator out of the box.

ViewPager.OnPageChangeListener pagerListener = new ViewPager.OnPageChangeListener() {
        boolean lastPageChange = false;

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels){
            int lastIdx = mPgScreenAdapter.getCount() - 1;

            Log.d(TAG, "pos:" + position);
            if(lastPageChange && position == lastIdx)
                PPIntent.changeScene(curAct, new Intent(curAct, LoginActivity.class), true);
        }
        @Override
        public void onPageSelected( int i) {
            pgText.setCurrentItem(i/2);
        }
        @Override
        public void onPageScrollStateChanged(int state) {
            int lastIdx = mPgScreenAdapter.getCount() - 1;

            int curItem = pgScreen.getCurrentItem();
            if(curItem==lastIdx /*&& lastPos==lastIdx*/  && state==1)   lastPageChange = true;
            else                                                         lastPageChange = false;
        }
    };
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!