WebView Show Loading progress

If you have embedded webview in your app and want to show loading progress until the page is fully loaded use the below code





        //find the webview
        WebView wview = (WebView)findViewById(R.id.webview);
        wview.setWebChromeClient(new WebChromeClient() {
            private ProgressDialog mProgress;

            @Override
            public void onProgressChanged(WebView view, int progress) {
                if (mProgress == null) {
                    mProgress = new ProgressDialog(mContext);
                    mProgress.show();
                }
                mProgress.setMessage("Loading " + String.valueOf(progress) + "%");
                if (progress == 100) {
                    mProgress.dismiss();
                    mProgress = null;
                }
            }
        });
        wview.loadUrl("http://www.androidlearner.com");






Comments