我在一个应用程序中工作,该应用程序具有用于在 webview 中加载的 url,在 andorid api 级别 13 之前一切正常,但对于 andorid ics 它的行为不同,一些 url 加载正确但有些导致加载时屏幕闪烁,我有不是具有 https 的网址,这些是简单的 http 网址。我不明白为什么会这样,请帮助我。 我的代码是-
progressDialog = ProgressDialog.show(WebViewActivity.this, "",
"Loading...");
progressDialog.setCancelable(true);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClientICS());
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
PluginState state = WebSettings.PluginState.ON;
webview.getSettings().setPluginState(state);
webview.getSettings().setDomStorageEnabled(true);
webview.setBackgroundColor(0);
webview.getSettings().setSupportZoom(true);
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
if (view.getProgress() == 100) {
progressDialog.dismiss();
}
}
webview.loadUrl(url);
}
private class MyWebViewClientICS extends WebViewClient {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
Log.d("onReceivedError", errorCode + "" + description
+ "failingUrl" + failingUrl);
Toast.makeText(WebViewActivity.this,
"Sorry, error in loading page, please try again",
Toast.LENGTH_SHORT).show();
finish();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
}
提前致谢
最佳答案
试试这个
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().supportZoom();
关于android - 在 android ics 中加载 url 时 webview 变为空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10595471/