Fragment + ViewPager + FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT(appcompat)
Fragment生命周期
MainHomeSubFirstFragment: onAttach MainHomeFragment: onAttachFragment: MainHomeSubFirstFragment MainHomeSubFirstFragment: onCreate MainHomeSubSecondFragment: onAttach MainHomeFragment: onAttachFragment: MainHomeSubSecondFragment MainHomeSubSecondFragment: onCreate MainHomeSubFirstFragment: onCreateView: cacheView is null MainHomeSubFirstFragment: onViewCreated MainHomeSubSecondFragment: onCreateView: cacheView is null MainHomeSubSecondFragment: onViewCreated MainHomeSubFirstFragment: onResume: parent show: true MainHomeSubFirstFragment: onResume: true, false
MainHomeSubThirdFragment: onAttach MainHomeFragment: onAttachFragment: MainHomeSubThirdFragment MainHomeSubThirdFragment: onCreate MainHomeSubThirdFragment: onCreateView: cacheView is null MainHomeSubThirdFragment: onViewCreated MainHomeSubFirstFragment: onPause MainHomeSubThirdFragment: onResume: parent show: true MainHomeSubThirdFragment: onResume: true, false
小结
- 不会调用setUserVisibleHint
- 预加载的Fragment不会调用onResume
来源:oschina
链接:https://my.oschina.net/u/219974/blog/4954230