WebViewClient中的shouldOverrideUrlLoading方法如下重写:
@Overridepublic boolean shouldOverrideUrlLoading(WebView view, String url){ view.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); view.loadUrl(url); return super.shouldOverrideUrlLoading(view, url);}onKeyDown如下重写:
@Overridepublic 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;}
取消
评论