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 genericOneButtonAlertWithListener(Context mContext, String title, String msg, String button, DialogInterface.OnClickListener listener) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); alertDialogBuilder.setTitle(title); alertDialogBuilder.setMessage(msg).setCancelable(true).setPositiveButton(button, listener); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it return alertDialog; } }