How to show progress dialog in Android?

后端 未结 16 3013
予麋鹿
予麋鹿 2020-11-28 07:40

I want to show ProgressDialog when I click on Login button and it takes time to move to another page. How can I do this?

16条回答
  •  生来不讨喜
    2020-11-28 08:27

    To use ProgressDialog use the below code

    ProgressDialog progressdialog = new ProgressDialog(getApplicationContext());
    progressdialog.setMessage("Please Wait....");
    

    To start the ProgressDialog use

    progressdialog.show();
    

    progressdialog.setCancelable(false); is used so that ProgressDialog cannot be cancelled until the work is done.

    To stop the ProgressDialog use this code (when your work is finished):

    progressdialog.dismiss();`
    

提交回复
热议问题