List of usage examples for android.app AlertDialog setTitle
@Override public void setTitle(CharSequence title)
From source file:org.rm3l.ddwrt.utils.Utils.java
@NotNull public static AlertDialog buildAlertDialog(@NotNull final Context context, @Nullable final String title, @NotNull final String msg, final boolean cancelable, final boolean cancelableOnTouchOutside) { @NotNull final AlertDialog alertDialog = new AlertDialog.Builder(context).create(); if (!Strings.isNullOrEmpty(title)) { alertDialog.setTitle(title); }//w w w.jav a2 s.c o m alertDialog.setMessage(msg); alertDialog.setCancelable(cancelable); alertDialog.setCanceledOnTouchOutside(cancelableOnTouchOutside); return alertDialog; }
From source file:com.streaming.sweetplayer.utils.Utils.java
/** * Function to show a dialog to the user about a current problem or inform about something happening. * * @param context Context//from ww w. j a v a 2 s. c o m * @param title String * @param message String */ public static void showAlertDialog(Context context, String title, String message) { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle(title); alertDialog.setMessage(message); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.show(); }
From source file:br.unicamp.busfinder.ServerOperations.java
public static void nextBuses(final String title, final Context c) { int stopid = Integer.parseInt(title.split("_")[0]); String req = BusFinderActivity.SERVER + "getNextBus?stopid="; JSONArray jar = getJSON(req + stopid); String display = ""; try {//from ww w . j a va 2s. co m for (int i = 0; i < jar.length(); i++) { JSONObject jos = jar.getJSONObject(i); String circular = jos.getString("circular"); String time = jos.getString("time"); display += "--" + circular + "------" + time + "\n"; } final String display_ = display; AlertDialog dialog = new AlertDialog.Builder(c).create(); dialog.setTitle(title); dialog.setMessage(display_); dialog.setCanceledOnTouchOutside(true); dialog.show(); return; } catch (JSONException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } Toast.makeText(c, "Error or no Connection ..", Toast.LENGTH_SHORT).show(); }
From source file:com.hemou.android.account.AccountUtils.java
/** * Show conflict message about previously registered authenticator from * another application/* ww w . ja va 2 s.c o m*/ * * @param activity */ private static void showConflictMessage(final Activity activity) { AlertDialog dialog = LightAlertDialog.create(activity); dialog.setTitle(activity.getString(string.authenticator_conflict_title)); dialog.setMessage(activity.getString(string.authenticator_conflict_message)); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { activity.finish(); } }); dialog.setButton(BUTTON_POSITIVE, activity.getString(android.R.string.ok), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.finish(); } }); dialog.show(); }
From source file:com.wellsandwhistles.android.redditsp.reddit.api.RedditAPICommentAction.java
public static void onActionMenuItemSelected(final RedditRenderableComment renderableComment, final RedditCommentView commentView, final AppCompatActivity activity, final CommentListingFragment commentListingFragment, final RedditCommentAction action, final RedditChangeDataManager changeDataManager) { final RedditComment comment = renderableComment.getParsedComment().getRawComment(); switch (action) { case UPVOTE://from ww w . j a v a 2s .c o m action(activity, comment, RedditAPI.ACTION_UPVOTE, changeDataManager); break; case DOWNVOTE: action(activity, comment, RedditAPI.ACTION_DOWNVOTE, changeDataManager); break; case UNVOTE: action(activity, comment, RedditAPI.ACTION_UNVOTE, changeDataManager); break; case SAVE: action(activity, comment, RedditAPI.ACTION_SAVE, changeDataManager); break; case UNSAVE: action(activity, comment, RedditAPI.ACTION_UNSAVE, changeDataManager); break; case REPORT: new AlertDialog.Builder(activity).setTitle(R.string.action_report) .setMessage(R.string.action_report_sure) .setPositiveButton(R.string.action_report, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { action(activity, comment, RedditAPI.ACTION_REPORT, changeDataManager); } }).setNegativeButton(R.string.dialog_cancel, null).show(); break; case REPLY: { final Intent intent = new Intent(activity, CommentReplyActivity.class); intent.putExtra(CommentReplyActivity.PARENT_ID_AND_TYPE_KEY, comment.getIdAndType()); intent.putExtra(CommentReplyActivity.PARENT_MARKDOWN_KEY, StringEscapeUtils.unescapeHtml4(comment.body)); activity.startActivity(intent); break; } case EDIT: { final Intent intent = new Intent(activity, CommentEditActivity.class); intent.putExtra("commentIdAndType", comment.getIdAndType()); intent.putExtra("commentText", StringEscapeUtils.unescapeHtml4(comment.body)); activity.startActivity(intent); break; } case DELETE: { new AlertDialog.Builder(activity).setTitle(R.string.accounts_delete).setMessage(R.string.delete_confirm) .setPositiveButton(R.string.action_delete, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { action(activity, comment, RedditAPI.ACTION_DELETE, changeDataManager); } }).setNegativeButton(R.string.dialog_cancel, null).show(); break; } case COMMENT_LINKS: final HashSet<String> linksInComment = comment.computeAllLinks(); if (linksInComment.isEmpty()) { General.quickToast(activity, R.string.error_toast_no_urls_in_comment); } else { final String[] linksArr = linksInComment.toArray(new String[linksInComment.size()]); final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setItems(linksArr, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { LinkHandler.onLinkClicked(activity, linksArr[which], false); dialog.dismiss(); } }); final AlertDialog alert = builder.create(); alert.setTitle(R.string.action_comment_links); alert.setCanceledOnTouchOutside(true); alert.show(); } break; case SHARE: final Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("text/plain"); mailer.putExtra(Intent.EXTRA_SUBJECT, "Comment by " + comment.author + " on Reddit"); // TODO this currently just dumps the markdown mailer.putExtra(Intent.EXTRA_TEXT, StringEscapeUtils.unescapeHtml4(comment.body) + "\r\n\r\n" + comment.getContextUrl().generateNonJsonUri().toString()); activity.startActivityForResult(Intent.createChooser(mailer, activity.getString(R.string.action_share)), 1); break; case COPY_TEXT: { ClipboardManager manager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); // TODO this currently just dumps the markdown manager.setText(StringEscapeUtils.unescapeHtml4(comment.body)); break; } case COPY_URL: { ClipboardManager manager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); // TODO this currently just dumps the markdown manager.setText(comment.getContextUrl().context(null).generateNonJsonUri().toString()); break; } case COLLAPSE: { commentListingFragment.handleCommentVisibilityToggle(commentView); break; } case USER_PROFILE: LinkHandler.onLinkClicked(activity, new UserProfileURL(comment.author).toString()); break; case PROPERTIES: CommentPropertiesDialog.newInstance(comment).show(activity.getSupportFragmentManager(), null); break; case GO_TO_COMMENT: { LinkHandler.onLinkClicked(activity, comment.getContextUrl().context(null).toString()); break; } case CONTEXT: { LinkHandler.onLinkClicked(activity, comment.getContextUrl().toString()); break; } case ACTION_MENU: showActionMenu(activity, commentListingFragment, renderableComment, commentView, changeDataManager, comment.isArchived()); break; case BACK: activity.onBackPressed(); break; } }
From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java
public static void deleteSeriesAlert(Context context, final CatalogueDBAdapter dbHelper, final Series series, final Runnable onDeleted) { // When we get here, we know the names are genuinely different and the old series is used in more than one place. String message = "Delete series"; try {//w ww .ja va 2 s .c o m message = String.format(context.getResources().getString(R.string.really_delete_series), series.name); } catch (NullPointerException e) { Logger.logError(e); } final AlertDialog alertDialog = new AlertDialog.Builder(context).setMessage(message).create(); alertDialog.setTitle(R.string.delete_series); alertDialog.setIcon(android.R.drawable.ic_menu_info_details); //alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { alertDialog.setButton2(context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dbHelper.deleteSeries(series); alertDialog.dismiss(); onDeleted.run(); } }); //alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { alertDialog.setButton(context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); }
From source file:de.wikilab.android.friendica01.Max.java
public static void alert(Context ctx, String text, String title, String okButtonText) { AlertDialog ad = new AlertDialog.Builder(ctx).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage(Html.fromHtml(text));/*from www. j a v a 2 s . c o m*/ ad.setTitle(title); ad.setButton(okButtonText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); ((TextView) ad.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java
public static void needLibraryThingAlert(final Context context, final boolean ltRequired, final String prefSuffix) { boolean showAlert; int msgId;//from w ww . j a va 2 s . c om final String prefName = LibraryThingManager.LT_HIDE_ALERT_PREF_NAME + "_" + prefSuffix; if (!ltRequired) { msgId = R.string.uses_library_thing_info; SharedPreferences prefs = context.getSharedPreferences("bookCatalogue", android.content.Context.MODE_PRIVATE); showAlert = !prefs.getBoolean(prefName, false); } else { msgId = R.string.require_library_thing_info; showAlert = true; } if (!showAlert) return; final AlertDialog dlg = new AlertDialog.Builder(context).setMessage(msgId).create(); dlg.setTitle(R.string.reg_library_thing_title); dlg.setIcon(android.R.drawable.ic_menu_info_details); dlg.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.more_info), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(context, AdministrationLibraryThing.class); context.startActivity(i); dlg.dismiss(); } }); if (!ltRequired) { dlg.setButton(DialogInterface.BUTTON_NEUTRAL, context.getResources().getString(R.string.disable_dialogue), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { SharedPreferences prefs = context.getSharedPreferences("bookCatalogue", android.content.Context.MODE_PRIVATE); SharedPreferences.Editor ed = prefs.edit(); ed.putBoolean(prefName, true); ed.commit(); dlg.dismiss(); } }); } dlg.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dlg.dismiss(); } }); dlg.show(); }
From source file:com.renren.api.connect.android.Util.java
/** * ???UI//from www . j ava 2s .c o m * * @param context * @param title * @param text */ public static void showAlert(Context context, String title, String text, boolean showOk) { AlertDialog alertDialog = new Builder(context).create(); alertDialog.setTitle(title); alertDialog.setMessage(text); if (showOk) { OnClickListener listener = null; alertDialog.setButton2("", listener); } alertDialog.show(); }
From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java
public static int deleteBookAlert(Context context, final CatalogueDBAdapter dbHelper, final long id, final Runnable onDeleted) { ArrayList<Author> authorList = dbHelper.getBookAuthorList(id); String title;//from ww w . ja va2s . c o m Cursor cur = dbHelper.fetchBookById(id); try { if (cur == null || !cur.moveToFirst()) return R.string.unable_to_find_book; title = cur.getString(cur.getColumnIndex(CatalogueDBAdapter.KEY_TITLE)); if (title == null || title.length() == 0) title = "<Unknown>"; } finally { if (cur != null) cur.close(); } // Format the list of authors nicely String authors; if (authorList.size() == 0) authors = "<Unknown>"; else { authors = authorList.get(0).getDisplayName(); for (int i = 1; i < authorList.size() - 1; i++) { authors += ", " + authorList.get(i).getDisplayName(); } if (authorList.size() > 1) authors += " " + context.getResources().getString(R.string.list_and) + " " + authorList.get(authorList.size() - 1).getDisplayName(); } // Get the title String format = context.getResources().getString(R.string.really_delete_book); String message = String.format(format, title, authors); final AlertDialog alertDialog = new AlertDialog.Builder(context).setMessage(message).create(); alertDialog.setTitle(R.string.menu_delete); alertDialog.setIcon(android.R.drawable.ic_menu_info_details); //alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { alertDialog.setButton2(context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dbHelper.deleteBook(id); alertDialog.dismiss(); onDeleted.run(); } }); //alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { alertDialog.setButton(context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); return 0; }