How to listen for a WebView finishing loading a URL?

前端 未结 17 1040
予麋鹿
予麋鹿 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:08

    I found one elegant solution as well, have not tested it rigorously though:

    public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                if (m_webView.getProgress() == 100) {
                    progressBar.setVisibility(View.GONE);
                    m_webView.setVisibility(View.VISIBLE);
                }
            } 
    

提交回复
热议问题