[英]Android: How to ignore or disable savedInstanceState?
I want to ignore or disable savedInstanceState so that the state of current activity won't save when I go to the next activity.我想忽略或禁用 savedInstanceState 以便当我将 go 保存到下一个活动时,当前活动的 state 不会保存。
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
Just this:只是这个:
public void onCreate(Bundle savedInstanceState){
super.onCreate(null);
Or this:或这个:
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.clear();
}
Write this line in your activity xml file:在您的活动 xml 文件中写入这一行:
android:saveEnabled="false"
Just override onRestoreInstanceState
without calling the super version只需覆盖
onRestoreInstanceState
而不调用超级版本
@Override
protected void onRestoreInstanceState(Bundle outState) {
//Just leave it empty
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.