Android examples for android.app:AlertDialog
show Alert Dialog with negative button
import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main{ public static void showAlertDialog(Context context, String title, String message, int iconId, String textButton) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title);/*from w ww .jav a 2s . c o m*/ builder.setMessage(message); builder.setCancelable(false); if (iconId > 0) builder.setIcon(iconId); builder.setNegativeButton(textButton, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } }