Dialog windows
On many occasions, in our apps, we will want to show the user some information or even ask for confirmation of an action in a pop-up window. This is known as a dialog window. If you quickly scan the palette in Android Studio, then you might be surprised to see that there is no mention whatsoever of dialogs.
Dialogs in Android are more advanced than a simple widget or even a whole layout. They are classes that can have layouts and other User Interface (UI) elements of their own.
The best way to create a dialog window in Android is to use the FragmentDialog
class.
Note
Fragments are a wide and vital topic in Android, and we will spend much of the second half of this book exploring and using them.
Creating a neat pop-up dialog (using FragmentDialog
) for our user to interact with is a great introduction to fragments, and it's not overly complicated at all.
Creating the Dialog Demo project
We previously mentioned that the best way to create a dialog...