首先要使其不是通过手机本身的浏览器来实现浏览网页而是通过这竖中个webview来实现所浏览清纤物的网页,
webView.setWebViewClient(new MyWebViewClient());
首先要定义一个progressDialog来实现中间显示加载进度和温馨提示
private class MyWebViewClient extends WebViewClient{
@Override
public void onPageStarted(WebView view, String url,Bitmap favicon) {//网答液页页面开始加载的时候
if (progressDialog == null) {
progressDialog=new ProgressDialog(MainActivity.this);
progressDialog.setMessage("数据加载中,请稍后。。。");
progressDialog.show();
webView.setEnabled(false);// 当加载网页的时候将网页进行隐藏
}
super.onPageStarted(view, url,favicon);
}
@Override
public void onPageFinished(WebView view, String url) {//网页加载结束的时候
//super.onPageFinished(view, url);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
progressDialog = null;
webView.setEnabled(true);
}
}
@Override
public boolean shouldOverrideUrlLoading(WebView view ,String url){ //网页加载时的连接的网址
view.loadUrl(url);
return false;
}
}
WebView webview = (WebView)findViewById(R.id.webview);
webview.setWebChromeClient(new WebChromeClient() {
链敏 public void onProgressChanged(WebView view, int progress) 棚轿枝{
//Activity和Webview根据加载程度决定进度条的进度大小
//当加载到100%的时候 进度帆唤条自动消失
context.setProgress(progress * 100);
}
});
webview.loadUrl(url);