一個 ViewPager中包含3個Fragment,Fragment隨Activity的生命週期如下。
三個Fragment從左到右依次是frist,second,thrid
打開Activity
03-24 13:15:51.622: V/first(3844): +onAttach+
03-24 13:15:51.622: V/first(3844): +onCreate+
03-24 13:15:51.622: V/first(3844): +onCreateView+
03-24 13:15:51.652: V/first(3844): +onActivityCreated+
03-24 13:15:51.652: V/first(3844): +onStart+
03-24 13:15:51.652: V/first(3844): +onResume+
03-24 13:15:51.652: V/second(3844): +onAttach+
03-24 13:15:51.652: V/second(3844): +onCreate+
03-24 13:15:51.652: V/second(3844): +onCreateView+
03-24 13:15:51.652: V/second(3844): +onActivityCreated+
03-24 13:15:51.652: V/second(3844): +onStart+
03-24 13:15:51.652: V/second(3844): +onResume+
切換到第二個標籤頁
03-24 13:16:12.852: V/third(3844): +onAttach+
03-24 13:16:12.852: V/third(3844): +onCreate+
03-24 13:16:12.852: V/third(3844): +onCreateView+
03-24 13:16:12.862: V/third(3844): +onActivityCreated+
03-24 13:16:12.862: V/third(3844): +onStart+
03-24 13:16:12.862: V/third(3844): +onResume+
切換到第三個標籤頁
03-24 13:16:18.212: V/first(3844): +onPause+
03-24 13:16:18.212: V/first(3844): +onStop+
03-24 13:16:18.212: V/first(3844): +onDestroyView+
再切回第二個
03-24 13:16:24.252: V/first(3844): +onCreateView+
03-24 13:16:24.292: D/AbsListView(3844): Get MotionRecognitionManager
03-24 13:16:24.302: V/first(3844): +onActivityCreated+
03-24 13:16:24.302: V/first(3844): +onStart+
03-24 13:16:24.312: V/first(3844): +onResume+
再切回第一個
03-24 13:16:43.952: V/third(3844): +onPause+
03-24 13:16:43.952: V/third(3844): +onStop+
03-24 13:16:43.952: V/third(3844): +onDestroyView+
再第二個標籤頁點HOME
03-24 13:17:55.032: V/first(3844): +onPause+
03-24 13:17:55.032: V/second(3844): +onPause+
03-24 13:17:55.032: V/third(3844): +onPause+
03-24 13:17:55.542: V/first(3844): +onStop+
03-24 13:17:55.542: V/second(3844): +onStop+
03-24 13:17:55.542: V/third(3844): +onStop+
再進入程序
03-24 13:17:58.232: V/first(3844): +onStart+
03-24 13:17:58.232: V/second(3844): +onStart+
03-24 13:17:58.232: V/third(3844): +onStart+
03-24 13:17:58.232: V/first(3844): +onResume+
03-24 13:17:58.232: V/second(3844): +onResume+
03-24 13:17:58.232: V/third(3844): +onResume+
退出程序
03-24 13:18:04.832: V/first(3844): +onPause+
03-24 13:18:04.832: V/second(3844): +onPause+
03-24 13:18:04.832: V/third(3844): +onPause+
03-24 13:18:05.232: V/first(3844): +onStop+
03-24 13:18:05.232: V/second(3844): +onStop+
03-24 13:18:05.232: V/third(3844): +onStop+
03-24 13:18:05.232: V/first(3844): +onDestroyView+
03-24 13:18:05.232: V/first(3844): +onDestroy+
03-24 13:18:05.232: V/first(3844): +onDetach+
03-24 13:18:05.232: V/second(3844): +onDestroyView+
03-24 13:18:05.232: V/second(3844): +onDestroy+
03-24 13:18:05.232: V/second(3844): +onDetach+
03-24 13:18:05.232: V/third(3844): +onDestroyView+
03-24 13:18:05.232: V/third(3844): +onDestroy+
03-24 13:18:05.232: V/third(3844): +onDetach+