package com.test; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.example.fragmenttest.R; public class TestFragment extends Fragment { int mIdx; public static TestFragment newInstance(int index) { TestFragment fragment = new TestFragment(); Bundle args = new Bundle(); args.putInt("index", index); fragment.setArguments(args); return fragment; } @Override public void onAttach(Activity activity) { Log.d(this.getClass().getSimpleName(), "onAttach()"); super.onAttach(activity); } @Override public void onCreate(Bundle savedInstanceState) { Log.d(this.getClass().getSimpleName(), "onCreate()"); super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args != null) { mIdx = args.getInt("index", 0); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(this.getClass().getSimpleName(), "onCreateView()"); return inflater.inflate(R.layout.layout_contents, null); } @Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { Log.d(this.getClass().getSimpleName(), "onInflate()"); super.onInflate(activity, attrs, savedInstanceState); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { Log.d(this.getClass().getSimpleName(), "onViewCreated()"); super.onViewCreated(view, savedInstanceState); } @Override public void onActivityCreated(Bundle savedInstanceState) { Log.d(this.getClass().getSimpleName(), "onActivityCreated()"); super.onActivityCreated(savedInstanceState); } @Override public void onStart() { Log.d(this.getClass().getSimpleName(), "onStart()"); super.onStart(); } @Override public void onResume() { Log.d(this.getClass().getSimpleName(), "onResume()"); super.onResume(); } @Override public void onPause() { Log.d(this.getClass().getSimpleName(), "onPause()"); super.onPause(); }
@Override public void onStop() { Log.d(this.getClass().getSimpleName(), "onStop()"); super.onStop(); } @Override public void onDestroyView() { Log.d(this.getClass().getSimpleName(), "onDestroyView()"); super.onDestroyView(); } @Override public void onDestroy() { Log.d(this.getClass().getSimpleName(), "onDestroy()"); super.onDestroy(); } @Override public void onDetach() { Log.d(this.getClass().getSimpleName(), "onDetach()"); super.onDetach(); } @Override public void onSaveInstanceState(Bundle outState) { Log.d(this.getClass().getSimpleName(), "onSaveInstanceState()"); super.onSaveInstanceState(outState); } } |