android webview旋转屏幕导致页面重新加载问题

来源:互联网 发布:软件开发北京 编辑:程序博客网 时间:2024/05/22 00:20

1. 在create时候加个状态判断
protected void onCreate(Bundle savedInstanceState){...  if (savedInstanceState == null)        {            mWebView.loadUrl("your_url");        }...}


2. 重载保存状态的函数:


    
@Override    protected void onSaveInstanceState(Bundle outState )    {        super.onSaveInstanceState(outState);        mWebView.saveState(outState);    }    @Override    protected void onRestoreInstanceState(Bundle savedInstanceState)    {        super.onRestoreInstanceState(savedInstanceState);        mWebView.restoreState(savedInstanceState);    }



阅读全文
1 0
原创粉丝点击