1、首先我们的布局文件要添加一个WebView
``
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</WebView>
``
2、然后在我们的activity中
``
WebSettings webSettings = webview.getSettings();
webSettings.setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36");
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setSaveFormData(false);
webview.setWebViewClient(webViewClient);
webview.loadUrl(Config.HOST+"app/resume/getAjax?cvId=1");
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedSslError(WebView view,
SslErrorHandler handler, SslError error) {
// TODO Auto-generated method stub
// super.onReceivedSslError(view, handler, error); 父类的默认处理方式,内部是handler.cancel(),必须去除
handler.proceed();// 接受所有网站的证书
// handleMessage(Message msg);// 进行其他处理
}
}
);
``
3、在这个类的最下面 自定义一下
``
WebViewClient webViewClient = new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return super.shouldOverrideUrlLoading(view, request);
}
};
``
4、OKOK大功告成!!
效果图