ViewPager默认缓存:
缓存当前Fragment左右各一个。
当黑屏或者home键时,缓存中的所有Fragment都会走一样的变化。
三个Fragment依次:OnePlaceholderFragment、TwoPlaceholderFragment、ThreePlaceholderFragment。
首次打开(生成OnePlaceholderFragment和TwoPlaceholderFragment):
OnePlaceholderFragment:
onCreate()--onCreateView()--onActivityCreated()--onStart()--onResume()
TwoPlaceholderFragment:
onCreate()--onCreateView()--onActivityCreated()--onStart()--onResume()
ThreePlaceholderFragment:
// 未生成
切换到TwoPlaceholderFragment(生成ThreePlaceholderFragment):
OnePlaceholderFragment:
// 无变化
TwoPlaceholderFragment:
// 无变化
ThreePlaceholderFragment:
onCreate()--onCreateView()--onActivityCreated()--onStart()--onResume()
切换到ThreePlaceholderFragment(移除OnePlaceholderFragment):
OnePlaceholderFragment:
// onPause()--onStop()--onDestroyView()
TwoPlaceholderFragment:
// 无变化
ThreePlaceholderFragment:
// 无变化
切回TwoPlaceholderFragment或者直接点击回到OnePlaceholderFragment:
OnePlaceholderFragment:
onCreateView()--onActivityCreated()--onStart()--onResume()
TwoPlaceholderFragment和ThreePlaceholderFragment按原规律变化