Progress Dialog is closed when touch on screen

后端 未结 4 2133
無奈伤痛
無奈伤痛 2021-01-01 17:53

I use a ProgressDialog in the thread. In the onButtonClick the thread is started, but when I touch anywhere on the screen the ProgressDialog<

4条回答
  •  情书的邮戳
    2021-01-01 18:14

    Add this to your dialog:

    yourDialog.setCanceledOnTouchOutside(false);
    

    In this way you can touch screen and the Dialog will be not canceled.

    EDIT

    If you are using DialogFragment, then you must use the following code snippet before calling show(FragmentManager mng, String tag):

    More info here.

    dialogFragment.setCancelable(false);
    

    EDIT 2

    Be careful with ProgressDialog , because with Android Oreo (v8.0) it is now deprecated.

提交回复
热议问题