Load fragment using tablayout

1

I have some fragments with TableLayout , it's in that order:

1, 2, 3, 4, 5, 6

I used the viewPager.setOffscreenPageLimit(5) method when creating my viewPager .

So far, okay, I do not want him to carry the fragments all the time and seOffscreenPageLimit solved this for me. But I need fragment 1 to reload every time I get into it.

Does anyone have a solution for this? or have you ever suffered from something like that? Thanks

    
asked by anonymous 25.03.2017 / 20:43

1 answer

0

You can use the ViewPager's setOnPageChangeListener method to know when the user is in position 1:

viewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int arg0) {
            //verifique se usuario esta na posicao 0 e atualize o fragment
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {}

        @Override
        public void onPageScrollStateChanged(int arg0) {}
    });
    
26.03.2017 / 05:16