当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Calling webservice in onpage selected of PagerTabStrip not smoothly scrolled, trying to load for every category

问题描述:

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) {

            }
        });
分享给朋友:
您可能感兴趣的文章:
随机阅读: