Java tutorial
//package com.java2s; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { public static void displayAlert(Context context, String title, String message, String buttonText) { AlertDialog alertDialog = new AlertDialog.Builder(context) .setPositiveButton(buttonText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).setTitle(title).setMessage(message).create(); alertDialog.show(); } public static void displayAlert(Context context, String title, String message, String buttonText, DialogInterface.OnClickListener buttonOnclick) { AlertDialog alertDialog = new AlertDialog.Builder(context).setPositiveButton(buttonText, buttonOnclick) .setTitle(title).setMessage(message).create(); alertDialog.show(); } }