Activity的保存与恢复
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Log.e("TAG", "保存应用状态"); outState.putString("e1", e1.getText().toString()); outState.putString("e2",e2.getText().toString()); outState.putString("e3",e3.getText().toString()); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); Log.e("TAG", "恢复应用状态"); e1.setText(savedInstanceState.getString("e1") + "恢复之后的"); e2.setText(savedInstanceState.getString("e2")+"恢复之后的"); e3.setText(savedInstanceState.getString("e3")+"恢复之后的"); }
点击事件的方法
关闭程序
public void guanbi(View v){ //关闭Activity finish();}
时间: 2024-10-13 22:50:28