问题描述:

I have used viewpager with pagertabstrip

I have called webservice in onpageselected but while moving to category every category trying to load so the scrolling was not moving smoothly.Is there any way to achieve only load webservice when category moved?

网友答案:

You can use following listener in which there is a method called onPageSelected(int position) you can handle your fragment or web service calling based on the position.

viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
相关阅读:
Top