Simple AlertDialog tutorial

How to create a AlertDialog to display a message in Android:

final AlertDialog alertDialog = new AlertDialog.Builder(YourActivity.this).create();
alertDialog.setTitle(getString(R.string.app_name));
alertDialog.setIcon(R.drawable.icon);
alertDialog.setMessage("Your message here");
alertDialog.setButton("Back", new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int which) {
			alertDialog.dismiss();
		}
});
alertDialog.show();
FacebookGoogle BookmarksTwitterFriendFeedGoogle GmailBlogger PostGoogle ReaderHotmailWordPressShare

Related posts:

  1. Android custom dialog with no title
  2. Simple pattern for opening an Android Activity
  3. EditText: handle text changes
  4. ProgressBar in Notification Area
  5. Back in Android’s WebView

Tags: , , , ,

Leave a Comment