有时,当我使用 loadUrl 加载我的 webview 时,网站不会显示,直到我触摸屏幕或滚动。
这就像我有一个 webview 绘图问题。
Context context = ctx;
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.website);
WebView webView = (WebView) dialog.findViewById(R.id.weburl);
webView.setScrollbarFadingEnabled(false);
//Disable the horizontal scroll bar
webView.setHorizontalScrollBarEnabled(false);
//Enable JavaScript
webView.getSettings().setJavaScriptEnabled(true);
//Set the user agent
webView.getSettings().setUserAgentString("AndroidWebView");
//Clear the cache
webView.clearCache(true);
webView.loadUrl("http://" + WebUrl);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url){
// do your handling codes here, which url is the requested url
// probably you need to open that url rather than redirect:
view.loadUrl(url);
view.setVisibility(View.VISIBLE);
return false; // then it is not handled by default action
}
@Override
public void onPageFinished(WebView view, String url) {
view.refreshDrawableState();
Log.v("FINISH","FINISH");
}
});
有谁知道我为什么会遇到这种问题。