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 action, often labeled with OK or Yes. This is the rightmost button when there are multiple buttons in the dialog.

• A neutral action—This button indicates that the user does not want to cancel or accept the action specified by the dialog. For example, an app that asks the user to register to gain access to additional features might provide a Remind Me Later neutral button.

We use AlertDialogs in this app for several purposes:

• To display a message to the user if either or both of the query and tag EditTexts are empty. This dialog will contain only a positive button.

• To display the Share, Edit and Delete options for a search. This dialog will contain a list of options and a negative button.

• To have the user confirm before deleting a search—in case the user accidentally touched the Delete option for a search.

You can learn more about Android dialogs at:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.161.188