List of usage examples for android.app AlertDialog.Builder setMessage
public void setMessage(CharSequence message)
From source file:com.todotxt.todotxttouch.util.Util.java
public static void showConfirmationDialog(Context cxt, int msgid, OnClickListener oklistener) { AlertDialog.Builder builder = new AlertDialog.Builder(cxt); // builder.setTitle(cxt.getPackageName()); builder.setMessage(msgid); builder.setPositiveButton(android.R.string.ok, oklistener); builder.setNegativeButton(android.R.string.cancel, null); builder.setCancelable(true);/*from w w w . j a va2 s. c om*/ builder.show(); }
From source file:com.todotxt.todotxttouch.util.Util.java
public static void showDeleteConfirmationDialog(Context cxt, OnClickListener oklistener) { AlertDialog.Builder builder = new AlertDialog.Builder(cxt); builder.setTitle(R.string.delete_task_title); builder.setMessage(R.string.delete_task_message); builder.setPositiveButton(R.string.delete_task_confirm, oklistener); builder.setNegativeButton(R.string.cancel, null); builder.show();//w w w. j av a2 s . c o m }
From source file:de.ub0r.android.lib.DonationHelper.java
/** * Show "donate" dialog.// w ww.j ava 2 s . c o m * * @param context * {@link Context} * @param title * title * @param btnDonate * button text for donate * @param btnNoads * button text for "i did a donation" * @param messages * messages for dialog body */ public static void showDonationDialog(final Activity context, final String title, final String btnDonate, final String btnNoads, final String[] messages) { final Intent marketIntent = Market.getInstallAppIntent(context, DONATOR_PACKAGE, null); String btnTitle = String.format(btnDonate, "Play Store"); SpannableStringBuilder sb = new SpannableStringBuilder(); for (String m : messages) { sb.append(m); sb.append("\n"); } sb.delete(sb.length() - 1, sb.length()); sb.setSpan(new RelativeSizeSpan(0.75f), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); AlertDialog.Builder b = new AlertDialog.Builder(context); b.setTitle(title); b.setMessage(sb); b.setCancelable(true); b.setPositiveButton(btnTitle, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { try { context.startActivity(marketIntent); } catch (ActivityNotFoundException e) { Log.e(TAG, "activity not found", e); Toast.makeText(context, "activity not found", Toast.LENGTH_LONG).show(); } } }); b.setNeutralButton(btnNoads, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse( "http://code.google.com/p/ub0rapps/downloads/list?" + "can=3&q=Product%3DDonator"))); } catch (ActivityNotFoundException e) { Log.e(TAG, "activity not found", e); Toast.makeText(context, "activity not found", Toast.LENGTH_LONG).show(); } } }); b.show(); }
From source file:com.todotxt.todotxttouch.util.Util.java
public static void showConfirmationDialog(Context cxt, int msgid, OnClickListener oklistener, int titleid) { AlertDialog.Builder builder = new AlertDialog.Builder(cxt); // builder.setTitle(cxt.getPackageName()); builder.setTitle(titleid);//from www .ja va2 s .c o m builder.setMessage(msgid); builder.setPositiveButton(android.R.string.ok, oklistener); builder.setNegativeButton(android.R.string.cancel, null); builder.setCancelable(true); builder.show(); }
From source file:com.otaupdater.utils.Utils.java
public static void showProKeyOnlyFeatureDialog(final Context ctx, final DialogCallback callback) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.prokey_only_feature_title); builder.setMessage(R.string.prokey_only_feature_message); builder.setPositiveButton(R.string.prokey_only_get, new DialogInterface.OnClickListener() { @Override// ww w . j ava 2s . co m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent i = new Intent(ctx, SettingsActivity.class); i.setAction(SettingsActivity.EXTRA_SHOW_GET_PROKEY_DLG); i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); ctx.startActivity(i); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (callback != null) callback.onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (callback != null) callback.onDialogClosed(dlg); } }); dlg.show(); }
From source file:org.ubicompforall.cityexplorer.CityExplorer.java
/** * Display a dialog that user has no Internet connection * Code from: http://osdir.com/ml/Android-Developers/2009-11/msg05044.html * @return /*from w w w. j a v a 2s .c o m*/ */ public static AlertDialog showNoConnectionDialog(final Context myContext, final String msg, final String cancelButtonStr, final Intent cancelIntent) { AlertDialog.Builder builder = new AlertDialog.Builder(myContext); builder.setCancelable(true); if (msg == "") { builder.setMessage(R.string.no_connection); } else { builder.setMessage(msg); } builder.setTitle(R.string.no_connection_title); builder.setPositiveButton(R.string.settings, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { myContext.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); } }); String cancelText = cancelButtonStr; if (cancelText == "") { cancelText = myContext.getResources().getString(R.string.cancel); } builder.setNegativeButton(cancelText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (cancelIntent != null) { if (myContext instanceof Activity) { ((Activity) myContext).startActivityForResult(cancelIntent, CityExplorer.REQUEST_LOCATION); } else { debug(-1, "This is not an Activity!!"); } dialog.dismiss(); } return; } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { if (myContext == null) { debug(0, "OOOPS!"); } else { Toast.makeText(myContext, "CANCELLED!", Toast.LENGTH_LONG).show(); if (cancelIntent != null) { myContext.startActivity(cancelIntent); } } return; } }); DATACONNECTION_NOTIFIED = true; return builder.show(); }
From source file:fr.cph.chicago.util.Util.java
/** * Function to show settings alert dialog */// w w w.ja va 2 s . c o m static void showSettingsAlert(@NonNull final Activity activity) { new Thread() { public void run() { activity.runOnUiThread(() -> { final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); alertDialogBuilder.setTitle("GPS settings"); alertDialogBuilder.setMessage( "GPS is not enabled. Do you want to go to settings main.java.fr.cph.chicago.res.menu?"); alertDialogBuilder.setCancelable(false).setPositiveButton("Yes", (dialog, id) -> { final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); activity.startActivity(intent); }).setNegativeButton("No", (dialog, id) -> dialog.cancel()); final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }); } }.start(); }
From source file:com.ibuildapp.romanblack.CataloguePlugin.utils.Utils.java
/** * Show alert dialog with passed params//w w w .ja v a 2 s . co m * * @param context context * @param title title of dialog * @param message message of dialog * @param positiveButtonText text of positive button (OK, for example) * @param negativeButtonText text of positive button (CANCEL, for example) * @param onDialogButtonClickListener listener of clicks dialog's buttons */ public static void showDialog(final Context context, final int title, final String message, final int positiveButtonText, final int negativeButtonText, final OnDialogButtonClickListener onDialogButtonClickListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message); builder.setTitle(title); builder.setCancelable(false); builder.setPositiveButton(positiveButtonText, onDialogButtonClickListener != null ? new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onDialogButtonClickListener.onPositiveClick(dialog); } } : null); builder.setNegativeButton(negativeButtonText, onDialogButtonClickListener != null ? new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onDialogButtonClickListener.onNegativeClick(dialog); } } : null); builder.create().show(); }
From source file:Main.java
/** * Creates a confirmation dialog with Yes-No Button. By default the buttons just dismiss the * dialog./*w w w . ja v a 2 s.c o m*/ * * @param ctx * @param message Message to be shown in the dialog. * @param yesListener Yes click handler * @param noListener * @param yesLabel Label for yes button * @param noLabel Label for no button * */ public static void showConfirmDialog(Context ctx, String message, DialogInterface.OnClickListener yesListener, DialogInterface.OnClickListener noListener, String yesLabel, String noLabel) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); if (yesListener == null) { yesListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }; } if (noListener == null) { noListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }; } builder.setMessage(message).setPositiveButton(yesLabel, yesListener).setNegativeButton(noLabel, noListener) .show(); }
From source file:fi.mikuz.boarder.util.FileProcessor.java
private static void notify(final Activity activity, final String text) { activity.runOnUiThread(new Runnable() { public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setMessage(text); builder.show();/*from w w w .j a v a 2 s. co m*/ } }); }