Android使用webview,触发网页中链接的事件 以及webview加载本地html、本apk内html和远程URL
??String strURI = ("file:///android_asset/first/first.html");?? //本地文件
// String strURI="http://www.baidu.com";????//网络文件
?//String strURI="content://com.android.htmlfileprovider/sdcard/index.html";? //打开本地sd卡内的index.html文件
??final WebView mWebView;
??mWebView = new WebView(this);??
??mWebView.loadUrl(strURI);?
?
?
mWebView.setWebViewClient(new WebViewClient() {
???// 得到请求时的错误
???public void onReceivedError(WebView view, int errorCode,
?????String description, String failingUrl) {
????System.out.println("2222222222222222222222222222222"
??????+ errorCode);
????
???}
???// 打开连接前的事件
???public boolean shouldOverrideUrlLoading(WebView view, String url) {
????mWebView.loadUrl(strURI1);
????return false;
????
???}
?
?});