Java tutorial
//package com.java2s; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { /** * Show a confirm/cancel dialog. * @param context The context to use. Usually your {@link Application} or {@link Activity} object. * @param titleId Resource id for the title string. * @param messageId Resource id for the message string. * @param yesId Resource id for the confirm button message string. * @param yesListener Listener for the confirm action. * @param noId Resource id for the cancel button message string. * @param noListener Listener for the cancel action. */ public static void showDialog(Context context, int titleId, int messageId, int yesId, DialogInterface.OnClickListener yesListener, int noId, DialogInterface.OnClickListener noListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(titleId); builder.setMessage(messageId); builder.setCancelable(false); builder.setPositiveButton(yesId, yesListener); builder.setNegativeButton(noId, noListener); builder.create().show(); } }