List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
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); alertDialogBuilder.setMessage(msg).setCancelable(true).setPositiveButton(button, new DialogInterface.OnClickListener() { @Override//w w w. jav a 2s . c o m public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); //finish(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it return alertDialog; }
From source file:Main.java
private static AlertDialog showDownloadDialog(final Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo, final String uriString) { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity); downloadDialog.setTitle(stringTitle); downloadDialog.setMessage(stringMessage); downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Uri uri = Uri.parse(uriString); Intent intent = new Intent(Intent.ACTION_VIEW, uri); activity.startActivity(intent); }//from ww w . j a v a 2 s. com }); downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }); return downloadDialog.show(); }
From source file:Main.java
/**To display alert dialog * @author wajdihh// ww w . java2s .com * Display dialog * @param pContext * @param pTitle * @param pMessage */ public static void showMessage(Context pContext, String pTitle, String pMessage) { if (Looper.getMainLooper() == Looper.myLooper()) { AlertDialog.Builder dialog = new AlertDialog.Builder(pContext); dialog.setTitle(pTitle); dialog.setMessage(pMessage); dialog.setNeutralButton("Ok", null); dialog.create().show(); } else Log.e("ShowMessageLog", pTitle + " : " + pMessage); }
From source file:Main.java
/** * Return an Alert Dialog with two buttons and a title. * @param context - The Activity which needs this alert dialog. * @param title - The title of the message. * @param message - The message in the alert. * @param positiveBtnLabel - The label of the positive button. * @param negetiveBtnLabel - The label of the negative button. * @param positiveClickListener- The onClickListener of the positive button. * @param negativeClickListener- The onClickListener of the negative button. * @return - The generated Alert Dialog. *///w w w. j a va2s .c o m public static AlertDialog.Builder getAlertDialogWithTwoButtonAndTitle(Context context, String title, String message, String positiveBtnLabel, String negetiveBtnLabel, DialogInterface.OnClickListener positiveClickListener, DialogInterface.OnClickListener negativeClickListener) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title); builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener) .setNegativeButton(negetiveBtnLabel, negativeClickListener); return builder; }
From source file:Main.java
public static void showDialog(Activity context, String strTitle, String strText, String BtnEnsure) { AlertDialog.Builder tDialog = new AlertDialog.Builder(context); // tDialog.setIcon(icon); tDialog.setTitle(strTitle); tDialog.setMessage(strText);/*from ww w.j a v a2s . c o m*/ tDialog.setPositiveButton(BtnEnsure, null); tDialog.show(); }
From source file:Main.java
/** * Generic error dialog with a close button. *///from w w w.j a v a 2s. c om 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:Main.java
public static void showAlertDialog(Context context, String title, String message, int iconId, String textButton) {/* w ww .ja va 2 s .c om*/ AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title); 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(); }
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); // 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();/*from w w w .j a v a 2s .co m*/ if (isFinish) ((Activity) context).finish(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:Main.java
public static void showYesNoPrompt(Context _context, String title, String message, OnClickListener onYesListener, OnClickListener onNoListener) { AlertDialog.Builder builder = new AlertDialog.Builder(_context); builder.setTitle(title); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setMessage(message);// w w w.j a v a2 s .com builder.setCancelable(false); builder.setPositiveButton("Yes", onYesListener); builder.setNegativeButton("No", onNoListener); 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
public static AlertDialog showTutorialDialog(final Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Watch a YouTube video tutorial?"); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setPositiveButton("Watch", new DialogInterface.OnClickListener() { @Override/*from ww w. ja va 2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("firstrun", false) .commit(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=LhiSWE5-ezM")); context.startActivity(browserIntent); } }); builder.setNeutralButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("firstrun", false) .commit(); dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); return alert; }