Creating an Alert Dialog Box
From time to time it may be necessary to alert the user to something that has happened. In the Task Reminder app, perhaps you want to display a welcome message and offer instructions on how to create a task. The Android system has a framework, built around dialog boxes that provide you with the implementation you may need.
Various types of dialog boxes are available:
Alert: Notifies the user of an important occurrence. Also allows you to set the text value of a button and the action to be performed when it’s clicked. As a developer, you can provide the AlertDialog
with a list of items to display, allowing the user to select from a list of items.
Progress: Used to display a progress wheel or bar. This type of dialog box is created via the ProgressDialog
class.
Custom: A custom dialog box created and programmed by you, the master Android developer. You create a custom dialog box class by extending the Dialog
base class or using custom layout XML files.
Seeing why you should work with dialog boxes
If you’ve never worked with an application that failed to alert you, or warn you appropriately, consider the example of an e-mail client not notifying you that ...
Get Android Application Development For Dummies, 2nd 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.