18 November, 2014

Android - ProgressDialog display before Loading Webpage in WebView

"How to implement progressBar or progressDialog while Webview loading Webpage?" I googled many times for this question and get best answer which i want to post here so it will be helpful to others also.

Basically User Interaction is main thing in any application and this question is also related to User Interaction.

You can implement it using setWebChromeClient() of WebView:

class MyWebChromeClient extends WebChromeClient {

    ProgressDialog pDialog;

    public MyWebChromeClient() {
        // TODO Auto-generated constructor stub
        pDialog = new ProgressDialog(YourActivity.this); //Use getActivity(); for Fragment


    public void onProgressChanged(WebView view, int progress) 
        if(progress < 100 && !pDialog.isShowing()){
        if(progress == 100) {
and you can set on your WebView like

webView.setWebChromeClient(new MyWebChromeClient());

I have posted this answer on stackoverflow also so you can visit and share it.

Any Question? You can ping me any time.

No comments:

Post a Comment