1 . 加载网页:
网络用:webView.loadUrl("http://www.baidu.com");
本地文件用:webView.loadUrl(file:///android_asset/XXX.html);这里的格式是固定的,文件位置 assets目录下
webview.postUrl(String url, byte[] postData) 加载页面使用Post方式,postData为参数
- //需要访问的网址
- String url = "http://www.baidu.com";
- //post访问需要提交的参数
- String postDate = "txtName=zzz&QueryTypeLst=1&CertificateTxt=dsds";
- //由于webView.postUrl(url, postData)中 postData类型为byte[] ,
- //通过EncodingUtils.getBytes(data, charset)方法进行转换
- webView.postUrl(url, EncodingUtils.getBytes(postDate, "BASE64"));