机器人的WebView处理方向更改机器人、方向、WebView

由网友(待我幼稚完)分享简介:刚开始使用的WebView工作。问题是性能下旋转。 web视图已重新加载页面,它可以是一个有点乏味。Just started working with the webview. The issue is performance following rotation. The WebView has to relo...

刚开始使用的WebView工作。问题是性能下旋转。 web视图已重新加载页面,它可以是一个有点乏味。

Just started working with the webview. The issue is performance following rotation. The WebView has to reload the page, which can be a bit tedious.

什么是最好的处理一个方向变化,而不从源头每次刷新页面?

What's the best of of handling an orientation change without reloading the page from source each time?

推荐答案

编辑:此方法不再起作用作为文档

This method no longer works as stated in the docs

原来的答复:

这可以通过overrwriting处理的onSaveInstanceState(包outState)在你的活动,并呼吁 saveState和从web视图:

This can be handled by overrwriting onSaveInstanceState(Bundle outState) in your activity and calling saveState from the webview:

   protected void onSaveInstanceState(Bundle outState) {
      webView.saveState(outState);
   }

然后恢复这在你的onCreate后的WebView已经重新充气课程:

Then recover this in your onCreate after the webview has been re-inflated of course:

public void onCreate(final Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.blah);
   if (savedInstanceState != null)
      ((WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);
}
阅读全文

相关推荐

最新文章