[Android] PageView 偵測到最後一頁的滑動




viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            int selectedIndex = 0;
            boolean fireRead;

            @Override
            public void onPageScrolled(int i, float v, int i2) {

                if(fireRead && i==Images.length-2){
                    Log.i("","event fire cancel ");
                    fireRead=false;
                }else if(fireRead && i==Images.length-1){
                    Log.i("","event fire");
                    fireRead=false;
                    //do something
                }
            }

            @Override
            public void onPageSelected(int i) {
                selectedIndex = i;
            }

            @Override
            public void onPageScrollStateChanged(int i) {
                if (selectedIndex == Images.length-1 && i == 1) {
                    Log.i("","event fire read ");
                    fireRead = true;
                }

            }
        });
        

提醒

本站內容即日起將轉到另一站上轉跳~