OnResume() not called in Fragment using tabLayout and ViewPager

前端 未结 2 507
后悔当初
后悔当初 2020-12-10 13:40

i\'m developing an app using tabLayout.

I\'ve a problem: When I try to reactivate a Fragment, the method OnResume is non calle

2条回答
  •  情话喂你
    2020-12-10 14:18

    The accepted answer did not work for me. However, I found a solution to the problem.

    Just initialise your FragmentStatePagerAdapter with the following constructor:

    public MyPagerAdapter(FragmentManager fm, int behaviour) {
        super(fm, behaviour);
    }
    

    like this :

    MyPagerAdapter myPagerAdapter = new MyPagerAdapter(getChildFragmentManager(), FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
    

提交回复
热议问题