List of usage examples for android.app AlertDialog.Builder setCancelable
public void setCancelable(boolean flag)
From source file:Main.java
/** * Creates a new Yes/No AlertDialog/*www. j a v a2s.c o m*/ * * @param context * @param dialogTitle * @param screenMessage * @param iconResourceId * @param listener * @return */ public static AlertDialog newYesNoDialog(final Context context, String dialogTitle, String screenMessage, int iconResourceId, OnClickListener listener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false); builder.setPositiveButton(android.R.string.yes, listener); builder.setNegativeButton(android.R.string.no, listener); builder.setTitle(dialogTitle); builder.setMessage(screenMessage); builder.setIcon(iconResourceId); return builder.create(); }
From source file:Main.java
/** * Creates a new AlertDialog to display a simple message * /* ww w . j a v a 2 s. co m*/ * @param context * @param dialogTitle * @param screenMessage * @param iconResourceId * @return */ public static AlertDialog newMessageDialog(final Context context, String dialogTitle, String screenMessage, int iconResourceId) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false); builder.setPositiveButton("Okay", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setTitle(dialogTitle); builder.setMessage(screenMessage); builder.setIcon(iconResourceId); return builder.create(); }
From source file:Main.java
public static void displayAlertDialog(String text, final Context context, final boolean closeActivity) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(text);/*from ww w.j av a 2 s . com*/ builder.setCancelable(false); builder.setNeutralButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { if (closeActivity) { ((Activity) context).finish(); } else { dialogInterface.dismiss(); } } }); AlertDialog dialog = builder.create(); dialog.show(); }
From source file:Main.java
public static void createNonCancellableAcceptOrCancelDialog(Context context, String title, String message, String acceptButtonText, String cancelButtonText, final Runnable onAccept, final Runnable onCancel) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false); builder.setTitle(title);// ww w .java 2s . c o m builder.setMessage(message); builder.setInverseBackgroundForced(true); builder.setPositiveButton(acceptButtonText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (onAccept != null) onAccept.run(); } }); builder.setNegativeButton(cancelButtonText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (onCancel != null) onCancel.run(); } }); AlertDialog alert = builder.create(); alert.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { return true; // Pretend we processed it } return false; // Any other keys are still processed as normal } }); alert.show(); }
From source file:Main.java
public static void showDialog(Context context, String title, String message, String buttonText, DialogInterface.OnClickListener buttonClickListener) { AlertDialog.Builder dlg = new AlertDialog.Builder(context); dlg.setTitle(title);/*from w ww . j av a2 s.c o m*/ dlg.setMessage(message); dlg.setCancelable(false); dlg.setPositiveButton(buttonText, buttonClickListener); dlg.create(); dlg.show(); }
From source file:Main.java
/** * Show a confirm/cancel dialog./*from www. ja v a2 s. c o m*/ * @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(); }
From source file:Main.java
public static void okButtonAlertDialog(String message, Context context) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(context); alertDialog.setMessage(message);/*from ww w. j a v a 2 s . c o m*/ alertDialog.setPositiveButton("Ok", null); alertDialog.setCancelable(false); alertDialog.show(); }
From source file:Main.java
public static void showDialogOkWithGoBack(String title, String message, final Activity activity) { if (activity.getApplicationContext() != null) { AlertDialog.Builder adb = new AlertDialog.Builder(activity); adb.setTitle(title);//from w w w . j a v a 2 s . co m adb.setMessage(message); adb.setCancelable(false); adb.setNeutralButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); //activity.onBackPressed(); } }); AlertDialog ad = adb.create(); ad.setVolumeControlStream(AudioManager.STREAM_MUSIC); ad.show(); } }
From source file:Main.java
public static void showMessage(Context _context, String title, String message, int icon, DialogInterface.OnClickListener ackHandler) { AlertDialog.Builder builder = new AlertDialog.Builder(_context); builder.setTitle(title);//from w ww. j a va 2 s . co m builder.setMessage(Html.fromHtml(message)); builder.setCancelable(false); builder.setPositiveButton("Acknowledged", ackHandler); builder.setIcon(icon); builder.show(); }
From source file:ca.frozen.curlingtv.App.java
public static void error(Context context, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message);/*from w w w. j a v a2 s.c o m*/ builder.setCancelable(true); builder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.show(); }