android webview client activity indicator

前端 未结 4 1726
粉色の甜心
粉色の甜心 2020-12-31 09:57

I got the code for showing activity indicator in a webview. I checked more than one reference and still I couldn\'t get it working. Can you please help me to debug my code b

4条回答
  •  一个人的身影
    2020-12-31 10:43

    Write below code in Activity's onCreate method.

    webView.setWebChromeClient(new ChromeClient());
    progress=ProgressDialog.show(this, "", "Loading...");
    webView.loadUrl(url);
    

    Create ChromeClient class in same activity.

     private class ChromeClient extends WebChromeClient {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if(newProgress >= 85) {
                progress.dismiss();
            }
            super.onProgressChanged(view, newProgress);
        }
    }
    

    Declare objects accordingly. Get back to me If you still face error. I will provide full source code.

提交回复
热议问题