ProgressBar progressBar=(ProgressBar)findViewById(R.id.progressBar);
//允许远行js
webview.getSettings().setJavaScriptEnabled(true);
//监听网页加载进度
webview.setWebViewClient(new WebViewClient(){
//网页加载开始时调用,显示加载提示旋转进度条
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(android.view.View.VISIBLE);
}
//网页加载完成时调用,隐藏加载提示旋转进度条
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
progressBar.setVisibility(android.view.View.GONE);
}
//网页加载失败时调用,隐藏加载提示旋转进度条
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// TODO Auto-generated method stub
super.onReceivedError(view, errorCode, description, failingUrl);
progressBar.setVisibility(android.view.View.GONE);
String str="file:///android_asset/html/err.html";
webview.loadUrl(str);
webview.setInitialScale(30);
}
});