I am rewriting my previous articles on Client Server Communication in Android as they are old and do not follow the best market practices (I was too young in android development that time to know the truth). They’ll hit the blog in a few days [No ETAs]. While I was working on the same project, I got need of creating a dialog box in my app to display some information about the app and credits. I did found enough information on android development website to start with the bare bones, but I was amazed to see the deprecated warning with the showDialog(DIALOG_ID); function call. To come up with another way, I dig my way around internet and found this working solution with 4.0.3 (API 15)

This app will demonstrate, how to create three basic DialogBox types:

  1. Default AlertDialog
  2. AlertDialog with List
  3. Custom Dialog with XML

To download the complete project you can fork the project on GitHub from this link: https://github.com/OsamaShabrez/Dialog-Boxes-in-Android

* Screen-shoots at the end of this post.

How to Display Default AlertDialog

 

How to Display AlertDialog with ListItems

This dialog box will display a list of 3 items; Red, Green and Blue and on selection the selected menu-item will be displayed on screen as toast message.

 

How To Display Dialog with Custom XML

 

XML Code:

 

Java Code:

 

Scree-Shoots