Android:在webview中多次加载数据后,会出现白色页面

Android:在webview中多次加载数据后,会出现白色页面,android,Android,当我在web视图中多次加载一些数据时,会出现白色页面…只需滚动它,数据就会返回..我注意到android 4.x上的这个问题…我在android 2.3.3 web视图中测试它工作正常 我能做些什么来防止这个问题?我面临着一个类似的问题,最终得到了解决,但我不知道为什么。成功的原因是: (一) 当我完成活动/片段的WebView onDestroy时,我有: @Override protected void onDestroy() { super.onDestroy(); if

当我在web视图中多次加载一些数据时,会出现白色页面…只需滚动它,数据就会返回..我注意到android 4.x上的这个问题…我在android 2.3.3 web视图中测试它工作正常


我能做些什么来防止这个问题?

我面临着一个类似的问题,最终得到了解决,但我不知道为什么。成功的原因是:

(一)

当我完成活动/片段的WebView onDestroy时,我有:

@Override
protected void onDestroy() {
    super.onDestroy();
    if (isFinishing()) {
      if (myWebView != null) {
        myWebView.destroy();
        myWebView = null;
      }
    }
}
(二)

我通过
myWebView.loadDataWithBaseURL(“file:///android_asset/,html_sourse,“text/html”,“UTF-8”,null)
而不是
myWebView.loadData(Uri.encode(html_源)、“text/html”、“utf-8”)。当我使用嵌入css的第二行时,html代码页不会出现,改为第一行(loadDataWithBaseURL),并向html代码中添加一个css from asset folder页面。我不明白为什么,但为我工作

3) (可选)

有时,如果您不关心保存历史记录,则使用clears会很有帮助:

   myWebView.clearHistory();
   myWebView.clearCache(true); 

我修复了加载完成后使用javascript滚动页面的问题