é¦å
è¦ä½¿å
¶ä¸æ¯éè¿ææºæ¬èº«çæµè§å¨æ¥å®ç°æµè§ç½é¡µèæ¯éè¿è¿ä¸ª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;
}
}
温馨提示:答案为网友推荐,仅供参考