2

我正在尝试在我的应用程序中将加载程序对话框添加到我的 web 视图中。那么,你能帮我解决这个问题吗?

这是我的 webview代码

public class AlTibbiWebViewActivity extends Activity {

private WebView wv;
private Intent incomingIntent = null;
private WebViewClient wvc = new WebViewClient() {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        wv.loadUrl(url);
        return true;
    }

};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.web_view);
    this.wv = (WebView) findViewById(R.id.webView);
    this.wv.setWebViewClient(wvc);
    wv.getSettings().setJavaScriptEnabled(true);
    this.incomingIntent = getIntent();
    String urlToLoad = incomingIntent.getExtras().getString("urlToLoad");

    //EXTRA HEADER MAP (remove header from web view )

     Map<String, String> aMap = new HashMap<String, String>() ;
     aMap.put("app", "no");
     //myMap = Collections.unmodifiableMap(aMap);
     wv.loadUrl(urlToLoad , aMap);

}
4

1 回答 1

4
webView.setWebViewClient(new WebViewClient() {

        public boolean shouldOverrideUrlLoading(WebView view, String url) {              
            view.loadUrl(url);
            return true;
        }
        public void onLoadResource (WebView view, String url) {
            if (progrDialog == null) {
                progrDialog = new ProgressDialog(YourActivity.this);
                progrDialog.setMessage("Loading...");
                progrDialog.show();
            }
        }
        public void onPageFinished(WebView view, String url) {
            try{
            if (progrDialog.isShowing()) {
                progrDialog.dismiss();
                progrDialog = null;
            }
            }catch(Exception exception){
                exception.printStackTrace();
            }
        }
    }); 
于 2012-10-11T08:49:31.700 回答