Fragment.java revision 2dedce6e84679ead961a485c7fe4b0f77c713b6a
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.app; 18 19import android.content.ComponentCallbacks; 20import android.content.res.Configuration; 21import android.os.Bundle; 22import android.view.LayoutInflater; 23import android.view.View; 24import android.view.ViewGroup; 25 26/** 27 * A Fragment is a piece of an application's user interface or behavior 28 * that can be placed in an {@link Activity}. 29 */ 30public class Fragment implements ComponentCallbacks { 31 static final int INITIALIZING = 0; // Not yet created. 32 static final int CREATED = 1; // Created. 33 static final int STARTED = 2; // Created and started, not resumed. 34 static final int RESUMED = 3; // Created started and resumed. 35 36 String mName; 37 38 int mState = INITIALIZING; 39 Activity mActivity; 40 41 boolean mCalled; 42 int mContainerId; 43 44 ViewGroup mContainer; 45 View mView; 46 47 public Fragment() { 48 } 49 50 public Fragment(String name) { 51 mName = name; 52 } 53 54 public String getName() { 55 return mName; 56 } 57 58 public Activity getActivity() { 59 return mActivity; 60 } 61 62 public void onAttach(Activity activity) { 63 mCalled = true; 64 } 65 66 public void onCreate(Bundle savedInstanceState) { 67 mCalled = true; 68 } 69 70 public View onCreateView(LayoutInflater inflater, ViewGroup container) { 71 return null; 72 } 73 74 public void onRestoreInstanceState(Bundle savedInstanceState) { 75 } 76 77 public void onStart() { 78 mCalled = true; 79 } 80 81 public void onRestart() { 82 mCalled = true; 83 } 84 85 public void onResume() { 86 mCalled = true; 87 } 88 89 public void onSaveInstanceState(Bundle outState) { 90 } 91 92 public void onConfigurationChanged(Configuration newConfig) { 93 mCalled = true; 94 } 95 96 public Object onRetainNonConfigurationInstance() { 97 return null; 98 } 99 100 public void onPause() { 101 mCalled = true; 102 } 103 104 public void onStop() { 105 mCalled = true; 106 } 107 108 public void onLowMemory() { 109 mCalled = true; 110 } 111 112 public void onDestroy() { 113 mCalled = true; 114 } 115 116 public void onDetach() { 117 mCalled = true; 118 } 119} 120