Dialog windows
Often 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 of dialog windows whatsoever.
Dialog windows in Android are more advanced than a simple widget or even a whole layout. They are classes that can also have layouts and other UI elements of their own.
The best way to create a dialog window in Android is to use the DialogFragment
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 DialogFragment
) for our user to interact with is, however, a great introduction to fragments and is not complicated at all.
Creating the dialog demo project
We previously mentioned that the best way to create a dialog window in Android is with the DialogFragment
class. However...