i\'m developing an app using tabLayout
.
I\'ve a problem: When I try to reactivate a Fragment
, the method OnResume
is non calle
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);
I've solved the problem. I use setUserVisibleHint(boolean isVisibileToUser) instead onResume(). Like this:
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if(isVisibleToUser) {
init();
} else {
}
}
Thank you all!