以下代码在所有运行 android 2.x 的设备中都可以正常工作,但在 Nexus 7 平板电脑中却没有 4.1.2
问题是 shouldOverrideUrlLoading 永远不会运行。onPageFinished 运行正常
我将不胜感激任何可用的帮助。
wv = (WebView) root_view.findViewById(R.id.wv);
wv.setBackgroundColor(res.getColor(R.color.def_bgr_color));
wv.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
wv.setWebViewClient(new MyWebViewClient() );
WebSettings web_settings = wv.getSettings();
web_settings.setJavaScriptEnabled(true);
web_settings.setLoadWithOverviewMode(true);
web_settings.setUseWideViewPort(false);
web_settings.setPluginsEnabled(true);
web_settings.setSupportZoom(true);
web_settings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
public class MyWebViewClient extends WebViewClient {
public MyWebViewClient() {
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.i(TAG, "RUN shouldOverrideUrlLoading" );
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Log.i(TAG, "RUN onPageFinished" );
}
}
String html_str = ... something html ...
wv.loadDataWithBaseURL("file:///android_asset/", html_str, "text/html", "utf-8", null);