How to listen for a WebView finishing loading a URL?

前端 未结 17 977
予麋鹿
予麋鹿 2020-11-22 05:40

I have a WebView that is loading a page from the Internet. I want to show a ProgressBar until the loading is complete.

How do I listen for

17条回答
  •  爱一瞬间的悲伤
    2020-11-22 06:21

    If you want show a progress bar you need to listen for a progress change event, not just for the completion of page:

    mWebView.setWebChromeClient(new WebChromeClient(){
    
                @Override
                public void onProgressChanged(WebView view, int newProgress) {
    
                    //change your progress bar
                }
    
    
            });
    

    BTW if you want display just an Indeterminate ProgressBar overriding the method onPageFinished is enough

提交回复
热议问题