Posts

Showing posts from 2010

Android Tutorial : Creating AlertDialog for Android Application

Image
I believe you guys reach here after searching on how to create an AlertDialog for Android. There are few types of Dialog (or also can consider as a Pop Up) is available in Android SDK. The easiest to work with is AlertDialog. This is the AlertDialog:  To do this is very simple. Below are the code snippet to create a simple AlertDialog for Android : (FYI: I'll skip all the import stuff as you can do it generally by Crtl + Shift + O / Organize Import - a function in eclipse to fill in all the import stuff for you ) // define a list of array final CharSequence[] shareItems = {"Facebook", "Twitter", "Email"}; // initiate a alert dialog builder AlertDialog.Builder builder = new AlertDialog.Builder(MediaNewsDetailActivity.this); builder.setTitle("Share this");   // set title for the AlertDialog builder.setItems(shareItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) {     // TODO A