Skip to content Skip to sidebar Skip to footer

"loading" Message When Starting Android App Doesn't Disappear

I would like to show a 'loading...' message when my Android . I managed to do this with the code below, but the problem is that it keeps displaying the 'Loading...' message, even w

Solution 1:

Dont put an exact timer unless you sure that loading will exactly take 3secs only. If you fetching the content from the net then I will suggest you to use asynctask and in the onpreexecute() show the loading dialog and in the onpostexecute() dissmiss the dialog. this works. Else If you sure then put wait(3000) and dissmiss the dialog

Solution 2:

Try this way :

webView.setWebChromeClient(new WebChromeClient() {
   publicvoidonProgressChanged(WebView view, int progress) {
       if (progressDialog == null) {
           progressDialog = new ProgressDialog(MainActivity.this);
           progressDialog.setMessage("Loading...");
           progressDialog.show();
       }

       if(progress==100 && progressDialog.isShowing()){
           progressDialog.dismiss();
           progressDialog = null;
       }
    }
 });

Post a Comment for ""loading" Message When Starting Android App Doesn't Disappear"