Android Dialogue

Android Dialogue

In Android, there is a small pop up window that prompts the user to make a decision. For example, “Continue, Yes or No”. Sometimes, it might prompt to add additional information as well. One of the critical features of Dialog control is that it will not take up the entire screen, and the user will still be able to view the primary application in the background. This control is primarily used for modal events, where the user needs to make a decision. The Dialog control belongs to the “Dialog” class, which contains other subclasses for Dialog. The following code in Kotlin shows how a Dialog control can be created with the AlertDialog subclass. With AlertDialog, it can show up to three distinct buttons with a title.

The Dialog class is like the root for dialogs, but you need to evade instantiating Dialog quickly. Alternatively, adopt one of the following subclasses:


The Dialog can display a headline, three buttons, a record of selectable things, and a design layout.

The DatePickerDialog or TimePickerDialog:

The Dialog with an already-defined UI lets users choose a date or time.
Such classes specify the style and formation for the Dialog, although you should apply a DialogFragment as a container box for the Dialog. A DialogFragment class gives you every control you want to organize the Dialog and control its display, rather than calling systems on the Dialog object. With the DialogFragment, you can handle the Dialog, and it perfectly handles all lifecycle situations, such as if the user touches the Back button or twists the screen. This class also allows the user to again use the Dialog's UI as an embeddable segment in a more extensive UI, mostly like the traditional Fragment (so as if you need the dialog UI to look uniquely on big and small screens).