Fragment.java revision ba51c3d02d08709e933de6f6c76dee3fd2f4bfa1
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.Context;
21import android.content.res.Configuration;
22import android.os.Bundle;
23import android.util.AttributeSet;
24import android.view.LayoutInflater;
25import android.view.View;
26import android.view.ViewGroup;
27
28/**
29 * A Fragment is a piece of an application's user interface or behavior
30 * that can be placed in an {@link Activity}.
31 */
32public class Fragment implements ComponentCallbacks {
33    static final int INITIALIZING = 0;  // Not yet created.
34    static final int CREATED = 1;       // Created.
35    static final int STARTED = 2;       // Created and started, not resumed.
36    static final int RESUMED = 3;       // Created started and resumed.
37
38    String mName;
39
40    int mState = INITIALIZING;
41    Activity mActivity;
42
43    boolean mCalled;
44    int mContainerId;
45
46    ViewGroup mContainer;
47    View mView;
48
49    public Fragment() {
50    }
51
52    public Fragment(String name) {
53        mName = name;
54    }
55
56    public String getName() {
57        return mName;
58    }
59
60    public Activity getActivity() {
61        return mActivity;
62    }
63
64    public void onInflate(Activity activity, AttributeSet attrs) {
65        mCalled = true;
66    }
67
68    public void onAttach(Activity activity) {
69        mCalled = true;
70    }
71
72    public void onCreate(Bundle savedInstanceState) {
73        mCalled = true;
74    }
75
76    public View onCreateView(LayoutInflater inflater, ViewGroup container) {
77        return null;
78    }
79
80    public void onRestoreInstanceState(Bundle savedInstanceState) {
81    }
82
83    public void onStart() {
84        mCalled = true;
85    }
86
87    public void onResume() {
88        mCalled = true;
89    }
90
91    public void onSaveInstanceState(Bundle outState) {
92    }
93
94    public void onConfigurationChanged(Configuration newConfig) {
95        mCalled = true;
96    }
97
98    public Object onRetainNonConfigurationInstance() {
99        return null;
100    }
101
102    public void onPause() {
103        mCalled = true;
104    }
105
106    public void onStop() {
107        mCalled = true;
108    }
109
110    public void onLowMemory() {
111        mCalled = true;
112    }
113
114    public void onDestroy() {
115        mCalled = true;
116    }
117
118    public void onDetach() {
119        mCalled = true;
120    }
121}
122