O'Reilly logo

Android™ Tablet Application Development For Dummies® by Donn Felker

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

Creating Your First Alert Dialog Box

Have you ever worked with an application that did not inform you of a warning or did not alert you of something? If not, take the following example into consideration. Imagine an e-mail client that does not inform you that you have new e-mail. How annoying would that be? Alerting users of important issues or choices that need to be made is an integral part of any user experience. A few examples of where you might want to use a dialog box to inform the user of a message and/or to have the user perform an action are as follows:

  • Something is happening in the background (this is what a ProgressDialog does).
  • The values in an EditText view are invalid.
  • The network has become unavailable.
  • The user needs to select a date or time (as I just demonstrated).
  • The state of the phone is not compatible with the application. Maybe the app needs to be GPS enabled or needs an SD Card, and you've detected these issues upon the application starting.
  • The user needs to choose from a list of items.

Although this is not a comprehensive list, it does give you an inkling of what is possible with dialog boxes.

The Android system has a framework built around dialog boxes that enables you to provide any implementation that you may need.

Various types of dialog boxes are available, including these, the most common:

  • Alert: Alerts the user of something important. Also allows the user to set the text value of the buttons, as well as the actions performed, when they are clicked. ...

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