How can I make a ProgressDialog be cancelable by t

2020-05-21 09:34发布

问题:

I would like to make a ProgressDialog cancelable by the back button but not by a screen tap. Currently I use setCancelable(true).

However, in some newer devices a tap on the screen also cancels the ProgressDialog. I'd like to disable the screen tap action while the ProgressDialog is shown.

回答1:

Use setCanceledOnTouchOutside(false).



回答2:

Try this it will help you:

ProgressDialog pd = ProgressDialog.show(main.this, "", "Loading. Please wait...", true);
pd.setCancelable(true);`