标签:
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Log.d(TAG,"onSaveInstanceState");
String str = mEditText.getText().toString();
if(!TextUtils.isEmpty(str)){
outState.putString(SAVE_MESSAGE, str);
}
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Log.d(TAG,"onRestoreInstanceState");
String str = savedInstanceState.getString(SAVE_MESSAGE);
if(!TextUtils.isEmpty(str)){
mEditText.setText(str);
}
}
当在设置android:configChanges=”orientation”时,竖屏切换为横屏 回调的方法如下:
此时不会自动保存屏幕原有的状态
横屏切换为竖屏回调的方法如下:
此时会保存屏幕原有的状态
当设置android:configChanges=”screenSize|orientation”时,横屏切换竖屏、竖屏切换横屏时,Activity中回调的方法均如下:
此时屏幕切换会保存其原有的状态
标签:
原文地址:http://blog.csdn.net/u011109530/article/details/51371934