Activity的生命周期
Fragment的生命周期
Activity与Fragment生命周期的区别
测试代码
- package com.goso.testapp;
- import android.app.Activity;
- import android.app.ListFragment;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- /**
- * Demonstration of using ListFragment to show a list of items
- * from a canned array.
- */
- public class FragmentListArray extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Log.e("HJJ", "Activity &&&& onCreate...");
- // Create the list fragment and add it as our sole content.
- if (getFragmentManager().findFragmentById(android.R.id.content) == null) {
- ArrayListFragment list = new ArrayListFragment();
- getFragmentManager().beginTransaction().add(android.R.id.content, list).commit();
- }
- }
- @Override
- protected void onStart() {
- // TODO Auto-generated method stub
- super.onStart();
- Log.e("HJJ", "Activity &&&& onStart...");
- }
- @Override
- protected void onResume() {
- // TODO Auto-generated method stub
- super.onResume