Dialog windows
In many situations in our apps, we will want to show the user some information, or perhaps 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, you might be surprised to see 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 themselves have layouts and other UI elements of their own.
The best way to create a dialog window in Android is to use the FragmentDialog
class.
Tip
Fragments are an extensive 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, however, a great introduction to fragments and not too complicated at all.
Creating the Dialog Demo project
We previously mentioned that the best way to create a dialog in Android is with the FragmentDialog
class. In Android...