码迷,mamicode.com
首页 > 其他好文 > 详细

fragment的生命周期

时间:2016-04-10 12:56:16      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:

  1 package com.example.myfragment;
  2 
  3 import android.app.Activity;
  4 import android.app.Fragment;
  5 import android.os.Bundle;
  6 import android.view.LayoutInflater;
  7 import android.view.View;
  8 import android.view.ViewGroup;
  9 
 10 public class Fragment1 extends Fragment {
 11 
 12     //3创建视图
 13     @Override
 14     public View onCreateView(LayoutInflater inflater, ViewGroup container,
 15             Bundle savedInstanceState) {
 16         // TODO Auto-generated method stub
 17         System.out.println("onCreateView");
 18         return inflater.inflate(R.layout.fragment1, null);
 19     }
 20 
 21     //2创建
 22     @Override
 23     public void onCreate(Bundle savedInstanceState) {
 24         // TODO Auto-generated method stub
 25         System.out.println("onCreate");
 26         super.onCreate(savedInstanceState);
 27     }
 28 
 29     //10销毁对象
 30     @Override
 31     public void onDestroy() {
 32         // TODO Auto-generated method stub
 33         System.out.println("onDestroy");
 34         super.onDestroy();
 35     }
 36 
 37     //6获取焦点
 38     @Override
 39     public void onResume() {
 40         // TODO Auto-generated method stub
 41         System.out.println("onResume");
 42         super.onResume();
 43     }
 44 
 45     //9销毁视图
 46     @Override
 47     public void onDestroyView() {
 48         // TODO Auto-generated method stub
 49         System.out.println("onDestroyView");
 50         super.onDestroyView();
 51     }
 52 
 53     //11解除绑定
 54     @Override
 55     public void onDetach() {
 56         // TODO Auto-generated method stub
 57         System.out.println("onDetach");
 58         super.onDetach();
 59     }
 60 
 61     //7失去焦点
 62     @Override
 63     public void onPause() {
 64         // TODO Auto-generated method stub
 65         System.out.println("onPause");
 66         super.onPause();
 67     }
 68 
 69     //4 activity创建后才可以显示
 70     @Override
 71     public void onActivityCreated(Bundle savedInstanceState) {
 72         // TODO Auto-generated method stub
 73         System.out.println("onActivityCreated");
 74         super.onActivityCreated(savedInstanceState);
 75     }
 76 
 77     //1绑定
 78     @Override
 79     public void onAttach(Activity activity) {
 80         // TODO Auto-generated method stub
 81         System.out.println("onAttach");
 82         super.onAttach(activity);
 83     }
 84 
 85     //5当可见
 86     @Override
 87     public void onStart() {
 88         // TODO Auto-generated method stub
 89         System.out.println("onStart");
 90         super.onStart();
 91     }
 92     //8不可见
 93     @Override
 94     public void onStop() {
 95         // TODO Auto-generated method stub
 96         System.out.println("onStop");
 97         super.onStop();
 98     }
 99 
100 }

 

fragment的生命周期

标签:

原文地址:http://www.cnblogs.com/zhongyinghe/p/5373687.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!