How can I make a ProgressDialog be cancelable by the back button but not by a screen tap?

徘徊边缘 提交于 2019-12-31 11:29:24

问题


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);`


来源:https://stackoverflow.com/questions/8100223/how-can-i-make-a-progressdialog-be-cancelable-by-the-back-button-but-not-by-a-sc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!