4.3.7. AlertDialog

You can display messages, options and confirmations to app users via AlertDialogs. While a dialog is displayed, the user cannot interact with the app—this is known as a modal dialog. As you’ll see, you specify the settings for the dialog with an AlertDialog.Builder object, then use it to create the AlertDialog.

AlertDialogs can display buttons, checkboxes, radio buttons and lists of items that the user can touch to respond to the dialog’s message. A standard AlertDialog may have up to three buttons that represent:

• A negative action—Cancels the dialog’s specified action, often labeled with Cancel or No. This is the leftmost button when there are multiple buttons in the dialog.

• A positive action—Accepts the dialog’s specified ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.