What is the difference between a dialog being dismissed or canceled in Android?

前端 未结 4 887
醉酒成梦
醉酒成梦 2020-12-02 05:27

Like the title says, what is the difference between a dialog being dismissed or canceled in Android?

4条回答
  •  情深已故
    2020-12-02 06:18

    dismiss is something you have to explicitly call in your code, usually to respond to a click event on a button in your Dialog. If you prefer, you can call dismissDialog in the Activity, which will in turn call dismiss on the Dialog.

    The cancel method only executes when it is explicitly called in your code, or when the user presses the BACK button when your cancelable Dialog is open (as @Lee noted).

    If you are using a DatePicker, then all of this is still the case. As @Lee said, DatePickerDialog.OnDateSetListener just detects when the user has chosen a date from the DatePicker.

    The Android Developer Reference provides more info on Dialogs.

提交回复
热议问题