Android-Show Custom Dialog

后端 未结 6 1715
忘了有多久
忘了有多久 2021-01-24 20:15

In my android application, I am using a custom dialog. When I try to show the dialog, it causes an error. I don\'t know what I am doing wrong, and I am really confused.

<
6条回答
  •  一整个雨季
    2021-01-24 20:35

    Documentation says:

    The Dialog class is the base class for creating dialogs. However, you typically should not instantiate a Dialog directly. Instead, you should use one of the following subclasses:

    AlertDialog

    ProgressDialog

    DatePickerDialog

    TimePickerDialog

    source: http://developer.android.com/guide/topics/ui/dialogs.html

    Google doesn't seems to give a reason for this on this document, or the actual API reference for the Dialog class. And as you already know, the error message doesn't either. So I'm not sure why the class is not 'protected'.

    Anyway, using one of the above classes should solve your issue.

    Please comment if anyone knows why we can't use the Dialog class directly.

提交回复
热议问题