Activity小结

Log日志类的五种级别

1、由高到低分别是:v、i、d、w、e

2、生命周期有七种状态:

onCreate:创建 
onStart:启动
onResume:显示(可以与用户交互)
onPause:暂停
onStop:停止(隐藏起来不与用户交互)
onRestart:重启动
onDestroy:销毁 (分为用户发起和垃圾回收发起)
3、常用代码:
Bundle:实际是一个Map,存储键值对(key,value)

protected void onSaveInstanceState(Bundle outState) {
    outState.putInt("mykey", i);

super.onSaveInstanceState(outState);
}

Bundle存储的值可以通过savedInstanceState.getInt("value")获取
rotected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);

int m =savedInstanceState.getInt("mykey");
Log.e("TAG","获取="+ m);//结果输出“获取=i”
}


4、View是所有控件视图的父类,可以进行强制转换,如:EditText et= (EditText)findViewById(R.id.et);

原文地址:https://www.cnblogs.com/shark1100913/p/5299743.html