我保存并恢复了视图,但是我松开了edittext,复选框等等。使用调试器,我可以看到所有这些字段都在" savedInstanceState" (在恢复部分中)但未显示;也许setcontentview是不够的? 预先感谢您的帮助。 MichelF
@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putInt("Screen",screenFlag);
savedInstanceState.putInt("PreviousScreen",previous_screenFlag);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
screenFlag = savedInstanceState.getInt("Screen");
previous_screenFlag = savedInstanceState.getInt("PreviousScreen");
switch (screenFlag){
case 1:
setContentView(R.layout.lay1);
break;
case 2:
setContentView(R.layout.dlay2);
break;
case 3:
setContentView(R.layout.lay3);
break;
default:
home(null);
}
}