Reputation: 191
I know that the Dialog
class is the base class for dialogs, but it says in the documentation that you should avoid instantiating Dialog
directly. Instead, you should use one of the following subclasses: AlertDialog
or DatePickerDialog
or TimePickerDialog
.
Why?
Upvotes: 17
Views: 16289
Reputation: 2655
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
when would i use an Alert Dialog?
-When i just want to inform something to the user .
-When we want use for a prompt like Do you want to go back (Yes, No, Cancel. Alert dialog comes with 3 buttons which are positive, negative and neutral which are provided by default).
-When i want to prompt user for a simple value (number/date/string...)
when would i use a Dialog?
-When i want to carry on a complex process with more buttons and widgets .
-Example:
Upvotes: 25
Reputation: 1217
Dialogs in Android are used to shows alerts for making decisions or to edit a single value. But there are some differences between an AlertDialog and a Dialog. In an AlertDialog you always want to show a message and at least one Button for user interaction. In a Dialog you have a custom view to a TextView or something more complex.
Upvotes: 4