List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
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);//from w ww . ja v a 2 s . c o m builder.setTitle(title); 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
/** * Will construct the AlertDialog.Builder object for convenience * /*from w w w. ja v a2 s .c om*/ * @param context * Application Context * @param message * Message to be displayed. * @return AlertDialog.Builder object with the message set. */ public static AlertDialog.Builder getDialogForStatus(Activity activity, String message, String title) { AlertDialog.Builder dialog = new AlertDialog.Builder(activity); dialog.setCancelable(false); if (!TextUtils.isEmpty(title)) { dialog.setTitle(title); } dialog.setMessage(message); return dialog; }
From source file:org.ptlug.ptwifiauth.Utilities.java
public static void showSimpleAlertDialog(Activity act, String title, String text, String button) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(act); alertDialog.setTitle(title); alertDialog.setMessage(text);//from www .j a v a 2 s.co m alertDialog.setCancelable(false); alertDialog.setPositiveButton(button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
From source file:Main.java
public static AlertDialog createAlert(String title, String message, Context context) { // Make an AlertDialog builder AlertDialog.Builder builder1 = new AlertDialog.Builder(context); //TODO: extract string // Set title/*www . ja va 2s. c om*/ builder1.setTitle(title); // Set message builder1.setMessage(message); // Set cancelable builder1.setCancelable(true); // Build a new neutral button dialog builder1.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { // On click of the neutral button public void onClick(DialogInterface dialog, int id) { // Cancel the dialog dialog.cancel(); } }); // Create the AlertDialog AlertDialog alert11 = builder1.create(); return alert11; }
From source file:Main.java
public static void showChangelog(final Context context, final String title, final String appname, final int resChanges, final int resNotes) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); final String v0 = p.getString(PREFS_LAST_RUN, ""); String v1 = null;/* ww w.ja v a 2s . c o m*/ try { v1 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { Log.e(TAG, "package not found: " + context.getPackageName(), e); } p.edit().putString(PREFS_LAST_RUN, v1).commit(); if (v0.length() == 0) { Log.d(TAG, "first boot, skip changelog"); // return; } if (v0.equals(v1)) { Log.d(TAG, "no changes"); return; } String[] changes = context.getResources().getStringArray(resChanges); String[] notes = resNotes > 0 ? context.getResources().getStringArray(resNotes) : null; final SpannableStringBuilder sb = new SpannableStringBuilder(); for (String s : notes) { SpannableString ss = new SpannableString(s + "\n"); int j = s.indexOf(":"); if (j > 0) { if (!TextUtils.isEmpty(s)) { ss.setSpan(new StyleSpan(Typeface.BOLD), 0, j, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } sb.append(ss); sb.append("\n"); } if (notes != null && notes.length > 0) { sb.append("\n"); } for (String s : changes) { s = appname + " " + s.replaceFirst(": ", ":\n* ").replaceAll(", ", "\n* ") + "\n"; SpannableString ss = new SpannableString(s); int j = s.indexOf(":"); if (j > 0) { ss.setSpan(new StyleSpan(Typeface.BOLD), 0, j, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } sb.append(ss); sb.append("\n"); } sb.setSpan(new RelativeSizeSpan(0.75f), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); changes = null; notes = null; AlertDialog.Builder b = new AlertDialog.Builder(context); b.setTitle(title); b.setMessage(sb); b.setCancelable(true); b.setPositiveButton(android.R.string.ok, null); b.show(); }
From source file:Main.java
public static void alertActivityFinish(final Activity activity, String msg) { AlertDialog.Builder ad = new AlertDialog.Builder(activity); ad.setIcon(activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert)); // Android Resource ad.setTitle("Sky Canvas").setMessage(msg).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // finish dialog dialog.dismiss();//from ww w. j a v a 2 s. c om activity.finish(); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); ad = null; }
From source file:Main.java
public static AlertDialog.Builder dialogBuilder(Context context, int title, View view) { AlertDialog.Builder builder = new AlertDialog.Builder(context); if (view != null) { builder.setView(view);//from w ww . j av a 2 s. c o m } if (title > 0) { builder.setTitle(title); } return builder; }
From source file:Main.java
/** * Shows a Dialog with a title, a message, a EditText and two Buttons for OK * and Cancel. The user can't click OK when the EditText is empty. * * @param context//from w w w. j a va 2 s . c om * The Context of the calling Activity * @param title * Title of the Dialog * @param message * Message of the Dialog * @param inputEditText * The EditText used for this Dialog. You can modify it for * example by setting the input type before passing it to this * method. You can also read the text from the calling method. * @param onOkClickListener * The Listener for clicking on the OK button. */ public static void showDialog(Context context, String title, String message, EditText inputEditText, DialogInterface.OnClickListener onOkClickListener) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title); alert.setMessage(message); alert.setView(inputEditText); /* * OK button */ alert.setPositiveButton(context.getString(android.R.string.ok), onOkClickListener); /* * Cancel button */ alert.setNegativeButton(context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* * Canceled. */ } }); final AlertDialog dialog = alert.show(); if (dialog != null) { /* * Disable ok button. */ dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false); /* * Dis- and enable , dependent on the text entered */ inputEditText.addTextChangedListener(new TextWatcher() { /** * Enable OK button if text entered, disable otherwise. */ public void onTextChanged(CharSequence s, int start, int before, int count) { dialog.getButton(DialogInterface.BUTTON_POSITIVE) .setEnabled(!s.toString().equals("") && isValideUrl(s.toString())); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); } }
From source file:Main.java
public static AlertDialog.Builder dialogBuilder(Context context, String title, String msg) { AlertDialog.Builder builder = new AlertDialog.Builder(context); if (msg != null) { builder.setMessage(msg);//from w w w. j a v a 2 s . co m } if (title != null) { builder.setTitle(title); } return builder; }
From source file:com.lge.friendsCamera.Utils.java
public static void showAlertDialog(Context context, String title, String message, DialogInterface.OnClickListener posListener) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title); alert.setMessage(message);//from ww w . ja v a2s . c o m alert.setPositiveButton("Ok", posListener); alert.setCancelable(false); alert.show(); }