O'Reilly logo

Android Programming: The Big Nerd Ranch Guide, Third Edition by Kristin Marsicano, Chris Stewart, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12 Dialogs

Dialogs demand attention and input from the user. They are useful for presenting a choice or important information. In this chapter, you will add a dialog in which users can change the date of a crime. Pressing the date button in CrimeFragment will present this dialog on Lollipop and later (Figure 12.1).

Figure 12.1  A dialog for picking the date of a crime

Screenshot shows the CriminalIntent app in Android. The Date of Crime shows a calendar with the date displayed as 2016 Mon, Nov 21.

The dialog in Figure 12.1 is an instance of AlertDialog, a subclass of Dialog. AlertDialog is the all-purpose Dialog subclass that you will use most often.

When Lollipop was released, dialogs were given a visual makeover. AlertDialogs on Lollipop automatically ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required