Java Code Examples for android.app.AlertDialog.Builder#setMessage()
The following examples show how to use
android.app.AlertDialog.Builder#setMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MMAlert.java From wechatsdk-xamarin with Apache License 2.0 | 6 votes |
public static AlertDialog showAlert(final Context context, final int msgId, final int titleId) { if (context instanceof Activity && ((Activity) context).isFinishing()) { return null; } final Builder builder = new AlertDialog.Builder(context); builder.setIcon(R.drawable.ic_dialog_alert); builder.setTitle(titleId); builder.setMessage(msgId); builder.setPositiveButton(R.string.app_ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); alert.show(); return alert; }
Example 2
Source File: Utils.java From BatteryFu with GNU General Public License v2.0 | 6 votes |
/** * Prompt user whether to proceed or not, if so, execute runnable * * @param context * @param titleResId * @param msgResId * @param onConfirm */ public static void confirm(Context context, String logTag, int titleResId, int msgResId, int OkResId, int cancelResId, final Runnable onConfirm) { AlertDialog dialog = null; try { Builder b = new Builder(context); b.setCancelable(true); if (titleResId >= 0) b.setTitle(titleResId); if (msgResId >= 0) b.setMessage(msgResId); if (cancelResId >= 0) b.setNegativeButton(cancelResId, null); if (onConfirm != null && OkResId >= 0) b.setPositiveButton(OkResId, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { onConfirm.run(); } }); b.create().show(); } catch (Exception e) { if (logTag != null) Utils.handleException(logTag, context, e); } }
Example 3
Source File: DialogUtils.java From caffeine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Show a model dialog box. The <code>android.app.AlertDialog</code> object is returned so that * you can specify an OnDismissListener (or other listeners) if required. * <b>Note:</b> show() is already called on the AlertDialog being returned. * * @param context The current Context or Activity that this method is called from. * @param message Message to display in the dialog. * @return AlertDialog that is being displayed. */ public static AlertDialog quickDialog(final Activity context, final String message) { final SpannableString s = new SpannableString(message); //Make links clickable Linkify.addLinks(s, Linkify.ALL); final Builder builder = new AlertDialog.Builder(context); builder.setMessage(s); builder.setPositiveButton(android.R.string.ok, closeDialogListener()); AlertDialog dialog = builder.create(); if(!context.isFinishing()) { dialog.show(); final TextView textView = (TextView) dialog.findViewById(android.R.id.message); if (textView != null) { textView.setMovementMethod(LinkMovementMethod.getInstance()); //Make links clickable } } return dialog; }
Example 4
Source File: MMAlert.java From wechatsdk-xamarin with Apache License 2.0 | 6 votes |
public static AlertDialog showAlert(final Context context, final String msg, final String title, final String yes, final String no, final DialogInterface.OnClickListener lOk, final DialogInterface.OnClickListener lCancel) { if (context instanceof Activity && ((Activity) context).isFinishing()) { return null; } final Builder builder = new AlertDialog.Builder(context); builder.setIcon(R.drawable.ic_dialog_alert); builder.setTitle(title); builder.setMessage(msg); builder.setPositiveButton(yes, lOk); builder.setNegativeButton(no, lCancel); // builder.setCancelable(false); final AlertDialog alert = builder.create(); alert.show(); return alert; }
Example 5
Source File: BaseActivity.java From Viewer with Apache License 2.0 | 5 votes |
public void openDialogMessage(int title,int message,boolean isCancelable){ final Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); builder.setMessage(message); builder.setCancelable(isCancelable); builder.setPositiveButton(R.string.ok_btn, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { builder.create().dismiss(); finish(); } }); builder.show(); }
Example 6
Source File: AlertDialogFragment.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle("Alert!"); alertDialog.setMessage("This is a notication dialog"); return alertDialog.create(); }
Example 7
Source File: CustomedDialog.java From evercam-android with GNU Affero General Public License v3.0 | 5 votes |
public static AlertDialog getSelectNewOwnerDialog(final Activity activity, final ArrayList<String> usernameList) { CharSequence[] listCharArray = usernameList.toArray(new CharSequence[usernameList.size()]); Builder dialogBuilder = new AlertDialog.Builder(activity) .setNegativeButton(R.string.cancel, null); if (usernameList.size() > 0) { dialogBuilder.setSingleChoiceItems(listCharArray, 0, null) .setPositiveButton(R.string.transfer, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ListView listView = ((AlertDialog) dialog).getListView(); Object checkedItem = listView.getAdapter().getItem(listView .getCheckedItemPosition()); String selectedUsername = checkedItem.toString(); if (activity instanceof SharingActivity) { TransferOwnershipTask.launch(activity, SharingActivity .evercamCamera.getCameraId(), selectedUsername); } } }).setTitle(R.string.transfer_select_title); } else { dialogBuilder.setMessage(R.string.msg_share_before_transfer); } return dialogBuilder.create(); }
Example 8
Source File: BaseActivity.java From Viewer with Apache License 2.0 | 5 votes |
public void openDialogMessage(int title,int message){ final Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); builder.setMessage(message); builder.setCancelable(true); builder.setPositiveButton(R.string.ok_btn, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { builder.create().dismiss(); } }); builder.show(); }
Example 9
Source File: SanaUtil.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static AlertDialog okCancelDialog(Context context, String title, String message, DialogInterface.OnClickListener okCancel) { Builder dialogBuilder = new Builder(context); dialogBuilder.setPositiveButton(context.getResources().getString( R.string.general_ok), okCancel); dialogBuilder.setTitle(title); dialogBuilder.setMessage(message); dialogBuilder.setNegativeButton(context.getResources().getString( R.string.general_cancel), okCancel); return dialogBuilder.create(); }
Example 10
Source File: ActivityDlgActionInput.java From LibreTasks with Apache License 2.0 | 5 votes |
public void onClick(View v) { Builder help = new AlertDialog.Builder(v.getContext()); help.setIcon(android.R.drawable.ic_menu_help); help.setTitle(R.string.help); help.setMessage(Html.fromHtml(getString(R.string.help_dlgactioninput))); help.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); help.show(); }
Example 11
Source File: ActivityDlgFilterInput.java From LibreTasks with Apache License 2.0 | 5 votes |
public void onClick(View v) { Builder help = new AlertDialog.Builder(v.getContext()); help.setIcon(android.R.drawable.ic_menu_help); help.setTitle(R.string.help); help.setMessage(Html.fromHtml(getString(R.string.help_dlgfilterinput))); help.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); help.show(); }
Example 12
Source File: ActivityMain.java From LibreTasks with Apache License 2.0 | 5 votes |
/** * Display our about dialog. */ private void showAbout() { // Get package information String version; try { PackageInfo pkgInfo; pkgInfo = getPackageManager().getPackageInfo(this.getPackageName(), 0); version = pkgInfo.versionName; } catch (NameNotFoundException e) { version = getString(R.string.unknown); } StringBuilder message = new StringBuilder(); message.append(getString(R.string.about_desc)).append("<br /><br />"); message.append(getString(R.string.copyright)).append("<br /><br />"); message.append(getString(R.string.about_version)).append(" ").append(version); message.append("<br /><br />"); message.append(getString(R.string.about_license)).append("<br /><br />"); message.append(getString(R.string.about_website)); Builder about = new AlertDialog.Builder(this); about.setTitle(R.string.about_title); about.setIcon(R.drawable.icon); about.setMessage(Html.fromHtml(message.toString())); about.setPositiveButton(R.string.ok, null); about.show(); }
Example 13
Source File: MMAlert.java From wechatsdk-xamarin with Apache License 2.0 | 5 votes |
public static AlertDialog showAlert(final Context context, final int msgId, final int titleId, final DialogInterface.OnClickListener l) { if (context instanceof Activity && ((Activity) context).isFinishing()) { return null; } final Builder builder = new AlertDialog.Builder(context); builder.setIcon(R.drawable.ic_dialog_alert); builder.setTitle(titleId); builder.setMessage(msgId); builder.setPositiveButton(R.string.app_ok, l); // builder.setCancelable(false); final AlertDialog alert = builder.create(); alert.show(); return alert; }
Example 14
Source File: AlertDialogFragment.java From barterli_android with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { if (savedInstanceState != null) { mTitleId = savedInstanceState.getInt(DialogKeys.TITLE_ID); mMessageId = savedInstanceState.getInt(DialogKeys.MESSAGE_ID); mNegativeLabelId = savedInstanceState .getInt(DialogKeys.NEGATIVE_LABEL_ID); mNeutralLabelId = savedInstanceState .getInt(DialogKeys.NEUTRAL_LABEL_ID); mPositiveLabelId = savedInstanceState .getInt(DialogKeys.POSITIVE_LABEL_ID); isCancellable = savedInstanceState .getBoolean(DialogKeys.CANCELLABLE); mIconId = savedInstanceState.getInt(DialogKeys.ICON_ID); mTheme = savedInstanceState.getInt(DialogKeys.THEME); mMessageParams = savedInstanceState .getStringArray(DialogKeys.MESSAGE_PARAMS); } final Builder builder = new Builder(getActivity(), mTheme); if ((mTitleId == 0) && (mMessageId == 0)) { throw new IllegalArgumentException("No Title and no message"); } if (mIconId != 0) { builder.setIcon(mIconId); } if (mTitleId != 0) { builder.setTitle(mTitleId); } if (mMessageId != 0) { if ((mMessageParams != null) && (mMessageParams.length > 0)) { builder.setMessage(getActivity() .getString(mMessageId, (Object[]) mMessageParams)); } else { builder.setMessage(mMessageId); } } if (mPositiveLabelId != 0) { builder.setPositiveButton(mPositiveLabelId, mClickListener); } if (mNegativeLabelId != 0) { builder.setNegativeButton(mNegativeLabelId, mClickListener); } if (mNeutralLabelId != 0) { builder.setNeutralButton(mNeutralLabelId, mClickListener); } builder.setCancelable(isCancellable); setCancelable(isCancellable); return builder.create(); }
Example 15
Source File: SettingsActivity.java From qBittorrent-Controller with MIT License | 4 votes |
public void genericOkDialog(int title, int message, DialogInterface.OnClickListener okListener) { if (!isFinishing()) { Builder builder = new Builder(this); // Title if (title != -1) { builder.setTitle(title); } // Message builder.setMessage(message); // Ok builder.setPositiveButton(R.string.ok, okListener); // Create dialog AlertDialog dialog = builder.create(); // Show dialog dialog.show(); } }
Example 16
Source File: Util.java From Klyph with MIT License | 3 votes |
/** * Display a simple alert dialog with the given text and title. * * @param context * Android context in which the dialog should be displayed * @param title * Alert dialog title * @param text * Alert dialog message */ public static void showAlert(Context context, String title, String text) { Builder alertBuilder = new Builder(context); alertBuilder.setTitle(title); alertBuilder.setMessage(text); alertBuilder.create().show(); }
Example 17
Source File: Util.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 3 votes |
/** * Display a simple alert dialog with the given text and title. * * @param context * Android context in which the dialog should be displayed * @param title * Alert dialog title * @param text * Alert dialog message */ @Deprecated public static void showAlert(Context context, String title, String text) { Builder alertBuilder = new Builder(context); alertBuilder.setTitle(title); alertBuilder.setMessage(text); alertBuilder.create().show(); }
Example 18
Source File: Util.java From FacebookImageShareIntent with MIT License | 3 votes |
/** * Display a simple alert dialog with the given text and title. * * @param context * Android context in which the dialog should be displayed * @param title * Alert dialog title * @param text * Alert dialog message */ @Deprecated public static void showAlert(Context context, String title, String text) { Builder alertBuilder = new Builder(context); alertBuilder.setTitle(title); alertBuilder.setMessage(text); alertBuilder.create().show(); }
Example 19
Source File: Util.java From Klyph with MIT License | 3 votes |
/** * Display a simple alert dialog with the given text and title. * * @param context * Android context in which the dialog should be displayed * @param title * Alert dialog title * @param text * Alert dialog message */ @Deprecated public static void showAlert(Context context, String title, String text) { Builder alertBuilder = new Builder(context); alertBuilder.setTitle(title); alertBuilder.setMessage(text); alertBuilder.create().show(); }
Example 20
Source File: Util.java From barterli_android with Apache License 2.0 | 3 votes |
/** * Display a simple alert dialog with the given text and title. * * @param context * Android context in which the dialog should be displayed * @param title * Alert dialog title * @param text * Alert dialog message */ @Deprecated public static void showAlert(Context context, String title, String text) { Builder alertBuilder = new Builder(context); alertBuilder.setTitle(title); alertBuilder.setMessage(text); alertBuilder.create().show(); }