List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:Main.java
/** * //from w w w. j a va2 s. c o m * @param context * @param title * @param message */ public static void showAlert(Context context, String title, String message) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle(title).setMessage(message).setCancelable(false).setNeutralButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close // current activity dialog.dismiss(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); }
From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java
private static void setupOnLinkClick(final Context context, final String url, final TextView textView) { textView.setOnClickListener(new View.OnClickListener() { @Override// www . ja v a 2 s .co m public void onClick(View v) { AlertDialog.Builder imageDialog = new AlertDialog.Builder(context); ProgressBar progressBar = new ProgressBar(context); imageDialog.setView(progressBar); AlertDialog progressDialog = imageDialog.create(); progressDialog.show(); new GetImageAsyncTask(new AsyncTaskCompletionNotifierImagePopup(context, progressDialog)) .execute(url); } }); }
From source file:Main.java
/** * showInformationDialog/*from w w w. j a v a2 s .c om*/ * * @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 AlertDialog genericOneButtonAlert(Context mContext, String title, String msg, String button) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); alertDialogBuilder.setTitle(title);/*from w w w.j a v a 2 s. c om*/ alertDialogBuilder.setMessage(msg).setCancelable(true).setPositiveButton(button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); //finish(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it return alertDialog; }
From source file:com.hybris.mobile.app.commerce.utils.UIUtils.java
/** * Show alert message//from w w w . j a va2s .c om * * @param context * @param title * @param message */ public static void showAlertMessage(Context context, String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, R.style.AlertDialogCustom)); builder.setTitle(title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(message).setCancelable(true) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:Main.java
static void showDialog(final Context context, String title, String message, final boolean isFinish) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle(title);//ww w. j av a2 s.c om // set dialog message alertDialogBuilder.setCancelable(false).setMessage(message).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); if (isFinish) ((Activity) context).finish(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:Main.java
public static void openAbout(Activity a) { Log.d("about", "openAbout has been called"); //Log.d("context", "context = "+ c.toString()); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(a); alertDialogBuilder.setTitle("About"); alertDialogBuilder.setMessage(/* w ww . j a v a 2 s. com*/ "This app was developed for CS160 at UC Berkeley by:\n\nDominic Kong \nPatrick Lin \nMeghana Seshadri \nJane Sima") .setCancelable(true).setNeutralButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:com.bt.download.android.gui.util.UIUtils.java
public static void showOkCancelDialog(Context context, View view, int titleId, OnClickListener okListener, OnClickListener cancelListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setView(view).setTitle(titleId).setPositiveButton(android.R.string.ok, okListener) .setNegativeButton(android.R.string.cancel, cancelListener); builder.create().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 ww w . ja v a 2s . c o m } 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(); }
From source file:Main.java
private static AlertDialog buildErrorDialog(final Activity context, String title, String description, String buttonText) {/* ww w. j ava 2 s. co m*/ AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title); builder.setMessage(description); builder.setCancelable(false); builder.setPositiveButton(buttonText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { new Handler().post(new Runnable() { @Override public void run() { dialog.dismiss(); context.finish(); } }); } }); return builder.create(); }