Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.widget.Toast; public class Main { public static AlertDialog AlertDialogSingle(final Context context, String Title, String Message, String ButtonName) { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); // Setting Dialog Title alertDialog.setTitle(Title); // Setting Dialog Message alertDialog.setMessage(Message); // Setting OK Button alertDialog.setButton(ButtonName, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to execute after dialog closed Toast.makeText(context, "You clicked on OK", Toast.LENGTH_SHORT).show(); dialog.dismiss(); } }); // Showing Alert Message return alertDialog; } }