Android onSaveInstanceState() Android 中 onSaveInstanceState()使用方法详解
人气:0想了解Android 中 onSaveInstanceState()使用方法详解的相关内容吗,在本文为您仔细讲解Android onSaveInstanceState()的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Android,onSaveInstanceState(),Android,中,onSaveInstanceState()使用方法,下面大家一起来学习吧。
Android 中 onSaveInstanceState()使用方法详解
覆盖onSaveInstanceState方法,并在onCreate中检测savedInstanceState和获取保存的值
@Override protected void onSaveInstanceState(Bundle outState) { outState.putInt("currentposition", videoView.getCurrentPosition()); super.onSaveInstanceState(outState); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); initView(); if (savedInstanceState != null && savedInstanceState.getInt("currentposition") != 0) { videoView.seekTo(savedInstanceState.getInt("currentposition")); } }
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
加载全部内容