posts - 93,  comments - 2,  trackbacks - 0

          官網幫助文檔鏈接:
           http://developer.android.com/guide/components/fragments.html

          主要看兩張圖,和跑代碼

          一,Fragment的生命周 

                    

          二,與Activity生命周期的對比

               

          場景演示 : 切換到該Fragment

          11-29 14:26:35.095: D/AppListFragment(7649): onAttach
          11-29 14:26:35.095: D/AppListFragment(7649): onCreate
          11-29 14:26:35.095: D/AppListFragment(7649): onCreateView
          11-29 14:26:35.100: D/AppListFragment(7649): onActivityCreated
          11-29 14:26:35.120: D/AppListFragment(7649): onStart
          11-29 14:26:35.120: D/AppListFragment(7649): onResume

          屏幕滅掉:

          11-29 14:27:35.185: D/AppListFragment(7649): onPause
          11-29 14:27:35.205: D/AppListFragment(7649): onSaveInstanceState
          11-29 14:27:35.205: D/AppListFragment(7649): onStop


          屏幕解鎖

          11-29 14:33:13.240: D/AppListFragment(7649): onStart
          11-29 14:33:13.275: D/AppListFragment(7649): onResume


          切換到其他Fragment:
          11-29 14:33:33.655: D/AppListFragment(7649): onPause
          11-29 14:33:33.655: D/AppListFragment(7649): onStop
          11-29 14:33:33.660: D/AppListFragment(7649): onDestroyView


          切換回本身的Fragment:

          11-29 14:33:55.820: D/AppListFragment(7649): onCreateView
          11-29 14:33:55.825: D/AppListFragment(7649): onActivityCreated
          11-29 14:33:55.825: D/AppListFragment(7649): onStart
          11-29 14:33:55.825: D/AppListFragment(7649): onResume

          回到桌面

          11-29 14:34:26.590: D/AppListFragment(7649): onPause
          11-29 14:34:26.880: D/AppListFragment(7649): onSaveInstanceState
          11-29 14:34:26.880: D/AppListFragment(7649): onStop

          回到應用

          11-29 14:36:51.940: D/AppListFragment(7649): onStart
          11-29 14:36:51.940: D/AppListFragment(7649): onResume


          退出應用

          11-29 14:37:03.020: D/AppListFragment(7649): onPause
          11-29 14:37:03.155: D/AppListFragment(7649): onStop
          11-29 14:37:03.155: D/AppListFragment(7649): onDestroyView
          11-29 14:37:03.165: D/AppListFragment(7649): onDestroy
          11-29 14:37:03.165: D/AppListFragment(7649): onDetach


          比Activity多了一些生命周期,完整和Activity對接上,大家好好利用。

          轉載:http://blog.csdn.net/forever_crying/article/details/8238863/

          posted on 2015-06-24 16:05 Terry Zou 閱讀(438) 評論(0)  編輯  收藏 所屬分類: Android
          <2015年6月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          Java

          搜索

          •  

          最新隨筆

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 车险| 松潘县| 通辽市| 那坡县| 新邵县| 新绛县| 万宁市| 无棣县| 绥阳县| 太谷县| 惠州市| 九寨沟县| 马公市| 阿拉善左旗| 老河口市| 柯坪县| 宁城县| 庆安县| 明水县| 绥棱县| 景宁| 得荣县| 深圳市| 政和县| 深泽县| 清镇市| 吉安市| 曲周县| 惠州市| 苏尼特左旗| 集安市| 巫溪县| 尚志市| 海口市| 繁峙县| 遂川县| 中江县| 泽普县| 宁强县| 三江| 邢台县|