(1)刚开始进来:
01-21 03:18:16.264: I/DD(1736): DoorManagerFragment======onAttach====== 01-21 03:18:16.264: I/DD(1736): DoorManagerFragment======onCreate====== 01-21 03:18:16.268: I/DD(1736): DoorManagerFragment======onCreateView====== 01-21 03:18:16.272: I/DD(1736): DoorManagerFragment======onActivityCreated====== 01-21 03:18:16.284: I/DD(1736): DoorManagerFragment======onStart====== 01-21 03:18:16.284: I/DD(1736): DoorManagerFragment======onResume====== 01-21 03:18:16.288: I/DD(1736): ClerkManagerFragment======onAttach====== 01-21 03:18:16.296: I/DD(1736): ClerkManagerFragment======onCreate====== 01-21 03:18:16.296: I/DD(1736): ClerkManagerFragment======onCreateView====== 01-21 03:18:16.316: I/DD(1736): ClerkManagerFragment======onActivityCreated====== 01-21 03:18:16.316: I/DD(1736): ClerkManagerFragment======onStart====== 01-21 03:18:16.316: I/DD(1736): ClerkManagerFragment======onResume======
加载的是第一个和第二个Fragment,第三个和第四个Fragment的生命周期没走。
当滑动到第二个Fragment就会加载第三个Fragment。
01-21 03:19:42.560: I/DD(1736): MemberManagerFragment======onAttach====== 01-21 03:19:42.564: I/DD(1736): MemberManagerFragment======onCreate====== 01-21 03:19:42.572: I/DD(1736): MemberManagerFragment======onCreateView====== 01-21 03:19:42.576: I/DD(1736): MemberManagerFragment======onActivityCreated====== 01-21 03:19:42.576: I/DD(1736): MemberManagerFragment======onStart====== 01-21 03:19:42.596: I/DD(1736): MemberManagerFragment======onResume======
当滑动到第三个Fragment就会销毁第一个Fragment的视图注意不是销毁实例,创建第四个Fragment。
01-21 03:20:56.468: I/DD(1736): DoorManagerFragment======onPause====== 01-21 03:20:56.468: I/DD(1736): DoorManagerFragment======onStop====== 01-21 03:20:56.476: I/DD(1736): DoorManagerFragment======onDestroyView====== 01-21 03:20:56.484: I/DD(1736): MyCenterFragment======onAttach====== 01-21 03:20:56.488: I/DD(1736): MyCenterFragment======onCreate====== 01-21 03:20:56.508: I/DD(1736): MyCenterFragment======onCreateView====== 01-21 03:20:56.508: I/DD(1736): MyCenterFragment======onActivityCreated====== 01-21 03:20:56.516: I/DD(1736): MyCenterFragment======onStart====== 01-21 03:20:56.520: I/DD(1736): MyCenterFragment======onResume======
当滑到第四个Fragment的时候就会销毁第二个Fragment的视图,由于他是最后一个Fragment,此时不会创建其他Fragment。
也就是说在ViewPager中在头尾部分维护着两个Fragment,在其他位置维护着三个Fragment。
时间: 2024-11-05 18:54:42