标签:
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 }
标签:
原文地址:http://www.cnblogs.com/zhongyinghe/p/5373687.html