private ProgressDialog progressBar;
private MainActivity ac;
public void loadUrl(WebView webView,String url,MainActivity acti) {
this.ac=acti;
if (webView != null) {
webView.loadUrl(url);
progressBar = ProgressDialog.show(ac,null,"页面加载中,请稍后..");
webView.reload();
}
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClientEmb());
}
public class WebViewClientEmb extends WebViewClient {
// 页面载入前调用
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (!progressBar.isShowing()) {
progressBar = ProgressDialog.show(ac,null,"页面加载中,请稍后..");
}
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
public void onPageFinished(WebView view, String url) {
progressBar.dismiss();
}
}
private MainActivity ac;
public void loadUrl(WebView webView,String url,MainActivity acti) {
this.ac=acti;
if (webView != null) {
webView.loadUrl(url);
progressBar = ProgressDialog.show(ac,null,"页面加载中,请稍后..");
webView.reload();
}
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClientEmb());
}
public class WebViewClientEmb extends WebViewClient {
// 页面载入前调用
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (!progressBar.isShowing()) {
progressBar = ProgressDialog.show(ac,null,"页面加载中,请稍后..");
}
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
public void onPageFinished(WebView view, String url) {
progressBar.dismiss();
}
}