发布网友 发布时间:2022-04-29 23:48
共3个回答
懂视网 时间:2022-04-21 05:55
这几天弄了下在webview中引入无线淘宝客页面,发现点击宝贝详情进入页面后,无法返回.mWebView = (WebView) findViewById(R.id.webView); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } });发现点击宝贝详情链接页面后,无法返回.各种方法都试了,就是解决不了!
mWebView = (WebView) findViewById(R.id.webView); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); } }); WebSettings webSettings = mWebView.getSettings(); //支持js webSettings.setJavaScriptEnabled(true); //支持对网页缩放 webSettings.setSupportZoom(true); //支持android4.0 webSettings.setBuiltInZoomControls(true); //默认缩放模式 webSettings.setDefaultZoom(ZoomDensity.CLOSE); mWebView.setInitialScale(100); //载入urlmWebView.loadUrl(" http://m.taobao.com/channel/chn/mobile/tejia_taoke.php?pid=mm_11443354_6190798_21526785");热心网友 时间:2022-04-21 03:03
WebViewClient中的shouldOverrideUrlLoading方法如下重写:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}onKeyDown如下重写:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if(keyCode==KeyEvent.KEYCODE_BACK){
if(webView.canGoBack()){
webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webView.goBack();
return true;
}else {
finish();
return true;
}
}
return false;
}
热心网友 时间:2022-04-21 04:21
你应该重写onkeydown事件了。先走了webview的canback