Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { public static AlertDialog genericTwoButtonAlertWithListener(Context mContext, String title, String msg, String yesButton, String noButton, DialogInterface.OnClickListener yesListener, DialogInterface.OnClickListener noListener) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); alertDialogBuilder.setTitle(title); alertDialogBuilder.setMessage(msg).setCancelable(true).setNegativeButton(noButton, noListener) .setPositiveButton(yesButton, yesListener); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it return alertDialog; } }