/** * Show confirmation dialog, OK and Cancel buttons * @param context Context * @param title Title * @param message Message * @param yesCallback Positive button callback */ static void showConfirm(Context context, CharSequence title, CharSequence message, DialogInterface.OnClickListener yesCallback) { AlertDialog alertDialog = initDialog(context, title, message); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
/** * Show information dialog with OK button * @param context Context * @param title Title * @param message Message */ static void showInfo(Context context, CharSequence title, CharSequence message) { AlertDialog alertDialog = initDialog(context, title, message); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, context.getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
private void show_noVideo_dialog() { AlertDialog dialog = new AlertDialog.Builder(context/**/).create(); dialog.setTitle(context.getString(R.string.error_no_video)); dialog.setMessage(context.getString(R.string.error_select_video_and_retry)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok).toUpperCase(), (dialog1, buttonId) -> dialog1.dismiss()); dialog.show(); }
public void homepageTutorial() { if (!sp.getBoolean("homepageLearned", false)) { AlertDialog dialog = new AlertDialog.Builder(context).create(); dialog.setTitle(context.getString(R.string.home)); dialog.setMessage(context.getString(R.string.homePageHelp)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", (dialog1, buttonId) -> { dialog1.dismiss(); SharedPreferences.Editor editor = sp.edit(); editor.putBoolean("homepageLearned", true); editor.apply(); }); dialog.show(); } }
/** * Validates the message and returns true if the form is valid. */ private boolean validate(@NonNull String message) { if (message.trim().length() == 0) { AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); alertDialog.setMessage(getString(R.string.shaky_empty_feedback_message)); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.shaky_empty_feedback_confirm), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); return false; } return true; } }
private void displayError(String errorMessage) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage(errorMessage); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); }
alert.setMessage(context.getString(R.string.torWarning)); alert.setCancelable(false); alert.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.enable), (dialog, buttonId) -> { torHelper.torEnable(); cookieItem.setChecked(false).setEnabled(false); }); alert.setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(android.R.string.cancel), (dialog, buttonId) -> item.setChecked(false)); alert.show();