首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Android施用webview,触发网页中链接的事件 以及webview加载本地html、本apk内html和远程URL

2012-08-24 
Android使用webview,触发网页中链接的事件以及webview加载本地html、本apk内html和远程URL??String strURI

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;
????
???}
?
?});

1 楼 mvpstevenlin 2012-04-20   // 打开连接前的事件
   public boolean shouldOverrideUrlLoading(WebView view, String url) {
    mWebView.loadUrl(strURI1);
    return false;
   
   }

strURI1 是什么?

热点排行