List of usage examples for android.app AlertDialog.Builder setMessage
public void setMessage(CharSequence message)
From source file:Main.java
/** * Generic error dialog with a close button. *///from w w w. j a va 2s .c o m public static void showDialog(String title, String message, Context context) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle(title); alertDialogBuilder.setMessage(message).setCancelable(false).setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:de.feanor.yeoldemensa.ExceptionHandler.java
/** * Displays an exception text to the user, along with explanatory error * message. This error message should be understandable even to * non-programmers and maybe help us when they give feedback. * //from w w w . jav a 2 s. c o m * Where Exceptions might occur, always use this method! App should never * crash without an info to the user. * * @param e * Exception to display * @param errorMessage * (Commonly understandable) error message to display. */ public static void displayException(Exception e, String errorMessage) { Log.e("yom", errorMessage + ": " + e.getMessage(), e); AlertDialog.Builder builder = new AlertDialog.Builder(YeOldeMensa.context); builder.setMessage(errorMessage + "\n\nDetail: " + e).setCancelable(false).setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.create().show(); }
From source file:Main.java
/** * showInformationDialog//w w w. ja v a 2 s. co m * * @param title * @param message * @param context * @param positiveListener * @param showNegativeOption */ public static void showInformationDialog(String title, String message, Context context, DialogInterface.OnClickListener positiveListener, boolean showNegativeOption) { AlertDialog.Builder alt_bld = new AlertDialog.Builder(context); alt_bld.setMessage(message); alt_bld.setCancelable(false); alt_bld.setPositiveButton("Aceptar", positiveListener); if (showNegativeOption) { alt_bld.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); } AlertDialog alert = alt_bld.create(); // Title for AlertDialog alert.setTitle(title); alert.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);/*w w w.j av a 2s. c om*/ builder.setMessage(Html.fromHtml(message)); builder.setCancelable(false); builder.setPositiveButton("Acknowledged", ackHandler); builder.setIcon(icon); boolean show = true; if (_context instanceof Activity) { Activity activity = (Activity) _context; if (activity.isFinishing()) { show = false; } } if (show) builder.show(); }
From source file:Main.java
/** * Dialog//from w ww . ja v a2 s .c o m * @param context * @param iconId * @param title * @param message * @param positiveBtnName * @param negativeBtnName * @param positiveBtnListener * @param negativeBtnListener * @return */ public static Dialog createConfirmDialog(Context context, int iconId, String title, String message, String positiveBtnName, String negativeBtnName, android.content.DialogInterface.OnClickListener positiveBtnListener, android.content.DialogInterface.OnClickListener negativeBtnListener) { Dialog dialog = null; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setIcon(iconId); builder.setTitle(title); builder.setMessage(message); builder.setPositiveButton(positiveBtnName, positiveBtnListener); builder.setNegativeButton(negativeBtnName, negativeBtnListener); dialog = builder.create(); return dialog; }
From source file:Main.java
/** * Show dialog and give 2 options: go to settings or leave the app * * @param activity the activity/* w w w . ja v a2s .c om*/ */ private static void showDialog(final Activity activity) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle("Bluetooth is turned off"); builder.setMessage("The Tapcentive Application requires Bluetooth to be turned ON"); builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent setnfc = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); activity.startActivity(setnfc); } }); builder.setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); activity.finish(); } }); builder.show(); }
From source file:Main.java
public static void yesNoMessage(final Activity activity, final String title, final String body, final String yesButtonLabel, final String noButtonLabel, final Runnable yesRunnable, final Runnable noRunnable) { activity.runOnUiThread(new Runnable() { @Override//from w w w . j a v a 2s . c om public void run() { AlertDialog.Builder dialog = new AlertDialog.Builder(activity); dialog.setTitle(title); dialog.setMessage(body); dialog.setPositiveButton(yesButtonLabel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (yesRunnable != null) yesRunnable.run(); } }); dialog.setNegativeButton(noButtonLabel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (noRunnable != null) noRunnable.run(); } }); dialog.create(); dialog.show(); } }); }
From source file:Main.java
/** * This method shows an alert box with specified message * @param context//from ww w.ja v a 2s .c o m * @param message */ public static void displayAlert(final Context context, String message) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle("Yumm! Alert:"); alert.setMessage(message); alert.setCancelable(false); alert.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:Main.java
public static AlertDialog showDownloadDialog(final Context ctx) { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(ctx); downloadDialog.setTitle("Layar is not available"); downloadDialog.setMessage("Do you want to download it from the market?"); downloadDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override/* w ww . j av a2 s.co m*/ public void onClick(DialogInterface dialogInterface, int i) { Uri uri = Uri.parse("market://details?id=com.layar"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); try { ctx.startActivity(intent); } catch (ActivityNotFoundException anfe) { Toast.makeText(ctx, "Market not installed", Toast.LENGTH_SHORT).show(); } } }); downloadDialog.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); return downloadDialog.show(); }
From source file:Main.java
public static void showConfirmDialog(Context context, String title, String message, String strPositiveButton, String strNegativeButton, DialogInterface.OnClickListener positiveOnclick, DialogInterface.OnClickListener negativeOnClick, boolean cancelAble, DialogInterface.OnCancelListener cancelListener) { if (context == null) { return;//from www . ja v a 2 s.c om } AlertDialog.Builder builder = new AlertDialog.Builder(context); if (title != null) { builder.setTitle(title); } builder.setMessage(message); if (TextUtils.isEmpty(strPositiveButton)) { builder.setPositiveButton(strPositiveButton, positiveOnclick); } else { builder.setPositiveButton(strPositiveButton, positiveOnclick); } if (!TextUtils.isEmpty(strNegativeButton)) { builder.setNegativeButton(strNegativeButton, negativeOnClick); } builder.setCancelable(cancelAble); builder.setOnCancelListener(cancelListener); builder.create().show(); }