Possible Duplicate:
Android Activity Life Cycle - difference between onPause() and OnStop()
我在想-what is the difference between 100 and 101 methods?
我认为onStart()
是一种多余的方法.onCreate()
将始终被调用(至少在我的前两个项目中).
有谁能解释其中的区别吗?
Possible Duplicate:
Android Activity Life Cycle - difference between onPause() and OnStop()
我在想-what is the difference between 100 and 101 methods?
我认为onStart()
是一种多余的方法.onCreate()
将始终被调用(至少在我的前两个项目中).
有谁能解释其中的区别吗?
看看活动的生命周期
哪里
***onCreate()***
在首次创建活动时调用.在这里,您应该进行所有常规的静态设置:创建视图、将数据绑定到列表等.此方法还为您提供了一个包含活动先前冻结状态(如果有)的Bundle 包.
***onStart()***
当活动对用户可见时调用.
您可以编写简单的类,以便在这些方法调用时查看一下
public class TestActivity extends Activity {
/** Called when the activity is first created. */
private final static String TAG = "TestActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i(TAG, "On Create .....");
}
/* (non-Javadoc)
* @see android.app.Activity#onDestroy()
*/
@Override
protected void onDestroy() {
super.onDestroy();
Log.i(TAG, "On Destroy .....");
}
/* (non-Javadoc)
* @see android.app.Activity#onPause()
*/
@Override
protected void onPause() {
super.onPause();
Log.i(TAG, "On Pause .....");
}
/* (non-Javadoc)
* @see android.app.Activity#onRestart()
*/
@Override
protected void onRestart() {
super.onRestart();
Log.i(TAG, "On Restart .....");
}
/* (non-Javadoc)
* @see android.app.Activity#onResume()
*/
@Override
protected void onResume() {
super.onResume();
Log.i(TAG, "On Resume .....");
}
/* (non-Javadoc)
* @see android.app.Activity#onStart()
*/
@Override
protected void onStart() {
super.onStart();
Log.i(TAG, "On Start .....");
}
/* (non-Javadoc)
* @see android.app.Activity#onStop()
*/
@Override
protected void onStop() {
super.onStop();
Log.i(TAG, "On Stop .....");
}
}
希望这能消除你的困惑.
详细信息请看here.
100 is a very good example and demo application, which is a very good article to understand the life cycle.