Android: How can i show progress bar while loading data into WebView?

后端 未结 4 1912
失恋的感觉
失恋的感觉 2021-01-06 10:21

How can I show the progress bar while loading data into my webview? My code :

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInsta         


        
4条回答
  •  囚心锁ツ
    2021-01-06 11:15

    Before calling loadData() function, just try to show ProgressDialog or put ProgressBar inside layout.

    And inside the WebViewClient, just dismiss() the progressDialog or make the ProgressBar invisible.

    for example:

    // when finish loading page
    public void onPageFinished(WebView view, String url) {
           if(mProgress.isShowing()) {
                 mProgress.dismiss();
           }
    }
    

    FYI, call loadData() or loadURL() only after you are done with web client setting.

    check this example: Load WebView with ProgressDialog

提交回复
热议问题