How to use a ProgressDialog in android

Progress dialog is used to show message and progress of any operation. when we show a Progress dialog it does not allow user to interact with the app. It is a independent modal window and it does not incorporate with the current activity layout.

Below is the code to show a simple progress Dialog. You can copy and paste this code in your activity.

  
       private ProgressDialog pDialog;

       Activity activity
      
       activity = this;

       pDialog = new ProgressDialog(activity);

       pDialog.setMessage("Your data is saving, please wait    ...");

       pDialog.setCancelable(false);
        
       pDialog.show();

It is customizable, more attributes and methods are available to change look and feel of a ProgressDialog.

Leave a Reply

Your email address will not be published. Required fields are marked *

four × four =