Java Code Examples for android.content.DialogInterface#BUTTON_NEUTRAL
The following examples show how to use
android.content.DialogInterface#BUTTON_NEUTRAL .
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: DownloadFragment.java From MHViewer with Apache License 2.0 | 6 votes |
private void showDirPickerDialogL() { DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: openDirPicker(); break; case DialogInterface.BUTTON_NEUTRAL: openDirPickerL(); break; } } }; new AlertDialog.Builder(getActivity()).setMessage(R.string.settings_download_pick_dir_l) .setPositiveButton(R.string.settings_download_continue, listener) .setNeutralButton(R.string.settings_download_document, listener) .show(); }
Example 2
Source File: SimpleHintAndInputDialog.java From BaseProject with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { int curClickedBtnType = DialogInterface.BUTTON_NEGATIVE; if (v == tvBtnCancel) { dismiss(); } else if (v == tvBtnCommit) { curClickedBtnType = DialogInterface.BUTTON_POSITIVE; } else if (v == ivBtnClose) { dismiss(); curClickedBtnType = DialogInterface.BUTTON_NEUTRAL; } if(dialogClickListener != null){ dialogClickListener.onClick(this, curClickedBtnType); } }
Example 3
Source File: ButtonBarDialogDecorator.java From AndroidMaterialDialog with Apache License 2.0 | 6 votes |
@Override public final Button getButton(final int whichButton) { switch (whichButton) { case DialogInterface.BUTTON_POSITIVE: return (positiveButton != null && positiveButton.getVisibility() == View.VISIBLE) ? positiveButton : null; case DialogInterface.BUTTON_NEGATIVE: return (negativeButton != null && negativeButton.getVisibility() == View.VISIBLE) ? negativeButton : null; case DialogInterface.BUTTON_NEUTRAL: return (neutralButton != null && neutralButton.getVisibility() == View.VISIBLE) ? neutralButton : null; default: return null; } }
Example 4
Source File: MLAlertController.java From NewXmPluginSDK with Apache License 2.0 | 6 votes |
/** * Sets a click listener or a message to be sent when the button is clicked. * You only need to pass one of {@code listener} or {@code msg}. * * @param whichButton Which button, can be one of * {@link DialogInterface#BUTTON_POSITIVE}, * {@link DialogInterface#BUTTON_NEGATIVE}, or * {@link DialogInterface#BUTTON_NEUTRAL} * @param text The text to display in positive button. * @param listener The * {@link DialogInterface.OnClickListener} to * use. * @param msg The {@link Message} to be sent when clicked. */ public void setButton(int whichButton, CharSequence text, DialogInterface.OnClickListener listener, Message msg) { if (msg == null && listener != null) { msg = mHandler.obtainMessage(whichButton, listener); } switch (whichButton) { case DialogInterface.BUTTON_POSITIVE: mButtonPositiveText = text; mButtonPositiveMessage = msg; break; case DialogInterface.BUTTON_NEGATIVE: mButtonNegativeText = text; mButtonNegativeMessage = msg; break; case DialogInterface.BUTTON_NEUTRAL: mButtonNeutralText = text; mButtonNeutralMessage = msg; break; default: throw new IllegalArgumentException("Button does not exist"); } }
Example 5
Source File: TypeSendFragment.java From Nimingban with Apache License 2.0 | 6 votes |
private void tryGettingCookies() { DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: showRegisterDialog(); break; case DialogInterface.BUTTON_NEGATIVE: showAddCookieDialog(); break; case DialogInterface.BUTTON_NEUTRAL: doAction(); break; } } }; new AlertDialog.Builder(getContext()).setTitle(R.string.no_cookies) .setMessage(R.string.no_cookies_ac) .setPositiveButton(R.string.register, listener) .setNegativeButton(R.string.add_cookies, listener) .setNeutralButton(R.string.i_dont_care, listener).show(); }
Example 6
Source File: AccountsSettingsFragment.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
@Override public void onClick(final DialogInterface dialog, final int which) { final String oldAccount = getSignedInAccountName(); switch (which) { case DialogInterface.BUTTON_POSITIVE: // Signed in final ListView lv = ((AlertDialog)dialog).getListView(); final String newAccount = (String) lv.getItemAtPosition(lv.getCheckedItemPosition()); getSharedPreferences() .edit() .putString(PREF_ACCOUNT_NAME, newAccount) .apply(); AccountStateChangedListener.onAccountSignedIn(oldAccount, newAccount); if (mDependentPreference != null) { mDependentPreference.setChecked(true); } break; case DialogInterface.BUTTON_NEUTRAL: // Signed out AccountStateChangedListener.onAccountSignedOut(oldAccount); getSharedPreferences() .edit() .remove(PREF_ACCOUNT_NAME) .apply(); break; } }
Example 7
Source File: CustomInputStylePreference.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
@Override public void onClick(final DialogInterface dialog, final int which) { super.onClick(dialog, which); switch (which) { case DialogInterface.BUTTON_POSITIVE: final boolean isEditing = !isIncomplete(); final SubtypeLocaleItem locale = (SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem(); final KeyboardLayoutSetItem layout = (KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem(); final InputMethodSubtype subtype = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype( locale.mLocaleString, layout.mLayoutName); setSubtype(subtype); notifyChanged(); if (isEditing) { mProxy.onSaveCustomInputStyle(this); } else { mProxy.onAddCustomInputStyle(this); } break; case DialogInterface.BUTTON_NEUTRAL: // Nothing to do break; case DialogInterface.BUTTON_NEGATIVE: mProxy.onRemoveCustomInputStyle(this); break; } }
Example 8
Source File: BrowserActivity.java From browser with GNU General Public License v2.0 | 5 votes |
private void onLinkLongClick2(final String url) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: newTab(url, false); break; case DialogInterface.BUTTON_NEGATIVE: getCurrentWebView().loadUrl(url); break; case DialogInterface.BUTTON_NEUTRAL: ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("label", url); clipboard.setPrimaryClip(clip); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog builder.setTitle(url) .setMessage(getResources().getString(R.string.dialog_link)) .setPositiveButton(getResources().getString(R.string.action_new_tab), dialogClickListener) .setNegativeButton(getResources().getString(R.string.action_open), dialogClickListener) .setNeutralButton(getResources().getString(R.string.action_copy), dialogClickListener).show(); }
Example 9
Source File: BrowserActivity.java From browser with GNU General Public License v2.0 | 5 votes |
private void onImageLongClickExtraUrl(final String newUrl) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: newTab(newUrl, true); break; case DialogInterface.BUTTON_NEGATIVE: getCurrentWebView().loadUrl(newUrl); break; case DialogInterface.BUTTON_NEUTRAL: if (API > 8) { Utils.downloadFile(mActivity, newUrl, getCurrentWebView().getUserAgent(), "attachment", false); } break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog builder.setTitle(newUrl.replace(Constants.HTTP, "")) .setMessage(getResources().getString(R.string.dialog_image)) .setPositiveButton(getResources().getString(R.string.action_new_tab), dialogClickListener) .setNegativeButton(getResources().getString(R.string.action_open), dialogClickListener) .setNeutralButton(getResources().getString(R.string.action_download), dialogClickListener).show(); }
Example 10
Source File: MongolAlertDialog.java From mongol-library with MIT License | 5 votes |
@Override public void handleMessage(Message msg) { switch (msg.what) { case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEUTRAL: ((DialogInterface.OnClickListener) msg.obj).onClick(mDialog.get(), msg.what); break; case MSG_DISMISS_DIALOG: ((DialogInterface) msg.obj).dismiss(); } }
Example 11
Source File: AlertController.java From ticdesign with Apache License 2.0 | 5 votes |
@Override public void handleMessage(Message msg) { switch (msg.what) { case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEUTRAL: ((DialogInterface.OnClickListener) msg.obj).onClick(mDialog.get(), msg.what); break; case MSG_DISMISS_DIALOG: ((DialogInterface) msg.obj).dismiss(); } }
Example 12
Source File: AlertController.java From ticdesign with Apache License 2.0 | 5 votes |
/** * Sets a click listener or a message to be sent when the button is clicked. * You only need to pass one of {@code listener} or {@code msg}. * @param whichButton Which button, can be one of * {@link DialogInterface#BUTTON_POSITIVE}, * {@link DialogInterface#BUTTON_NEGATIVE}, or * {@link DialogInterface#BUTTON_NEUTRAL} * @param text The text to display in button. * @param icon The icon to display in button. * @param listener The {@link DialogInterface.OnClickListener} to use. * @param msg The {@link Message} to be sent when clicked. */ public void setButton(int whichButton, CharSequence text, Drawable icon, DialogInterface.OnClickListener listener, Message msg) { if (msg == null && listener != null) { msg = mHandler.obtainMessage(whichButton, listener); } switch (whichButton) { case DialogInterface.BUTTON_POSITIVE: mButtonBundlePositive.buttonText = text; mButtonBundlePositive.buttonIcon = icon; mButtonBundlePositive.buttonMessage = msg; break; case DialogInterface.BUTTON_NEGATIVE: mButtonBundleNegative.buttonText = text; mButtonBundleNegative.buttonIcon = icon; mButtonBundleNegative.buttonMessage = msg; break; case DialogInterface.BUTTON_NEUTRAL: mButtonBundleNeutral.buttonText = text; mButtonBundleNeutral.buttonIcon = icon; mButtonBundleNeutral.buttonMessage = msg; break; default: throw new IllegalArgumentException("Button does not exist"); } }
Example 13
Source File: MemorizingActivity.java From Yahala-Messenger with MIT License | 5 votes |
public void onClick(DialogInterface dialog, int btnId) { int decision; dialog.dismiss(); switch (btnId) { case DialogInterface.BUTTON_POSITIVE: decision = MTMDecision.DECISION_ALWAYS; break; case DialogInterface.BUTTON_NEUTRAL: decision = MTMDecision.DECISION_ONCE; break; default: decision = MTMDecision.DECISION_ABORT; } sendDecision(decision); }
Example 14
Source File: ButtonBarDialogDecorator.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Adapts the dialog's neutral button. */ private void adaptNeutralButton() { if (neutralButton != null) { neutralButton.setText(neutralButtonText != null ? neutralButtonText.toString().toUpperCase(Locale.getDefault()) : null); OnClickListenerWrapper onClickListener = new OnClickListenerWrapper(neutralButtonListener, false, getDialog(), DialogInterface.BUTTON_NEUTRAL); neutralButton.setOnClickListener(onClickListener); neutralButton.setVisibility( !TextUtils.isEmpty(neutralButtonText) ? View.VISIBLE : View.GONE); adaptButtonBarContainerVisibility(); } }
Example 15
Source File: MemorizingActivity.java From tapchat-android with Apache License 2.0 | 5 votes |
@Override public void onClick(DialogInterface dialog, int btnId) { dialog.dismiss(); switch (btnId) { case DialogInterface.BUTTON_POSITIVE: sendDecision(MTMDecision.DECISION_ALWAYS); break; case DialogInterface.BUTTON_NEUTRAL: sendDecision(MTMDecision.DECISION_ONCE); break; default: sendDecision(MTMDecision.DECISION_ABORT); } }
Example 16
Source File: AlertController.java From ticdesign with Apache License 2.0 | 5 votes |
public FloatingActionButton getIconButton(int whichButton) { switch (whichButton) { case DialogInterface.BUTTON_POSITIVE: return mButtonBundlePositive.iconButton; case DialogInterface.BUTTON_NEGATIVE: return mButtonBundleNegative.iconButton; case DialogInterface.BUTTON_NEUTRAL: return mButtonBundleNeutral.iconButton; default: return null; } }
Example 17
Source File: HomeScreenBaseActivity.java From commcare-android with Apache License 2.0 | 5 votes |
private void createAskUseOldDialog(final AndroidSessionWrapper state, final SessionStateDescriptor existing) { final AndroidCommCarePlatform platform = CommCareApplication.instance().getCommCarePlatform(); String title = Localization.get("app.workflow.incomplete.continue.title"); String msg = Localization.get("app.workflow.incomplete.continue"); StandardAlertDialog d = new StandardAlertDialog(this, title, msg); DialogInterface.OnClickListener listener = (dialog, i) -> { switch (i) { case DialogInterface.BUTTON_POSITIVE: // use the old form instance and load the it's state from the descriptor state.loadFromStateDescription(existing); formEntry(platform.getFormDefId(state.getSession().getForm()), state.getFormRecord()); break; case DialogInterface.BUTTON_NEGATIVE: // delete the old incomplete form FormRecordCleanupTask.wipeRecord(existing); // fallthrough to new now that old record is gone case DialogInterface.BUTTON_NEUTRAL: // create a new form record and begin form entry state.commitStub(); formEntry(platform.getFormDefId(state.getSession().getForm()), state.getFormRecord()); } dismissAlertDialog(); }; d.setPositiveButton(Localization.get("option.yes"), listener); d.setNegativeButton(Localization.get("app.workflow.incomplete.continue.option.delete"), listener); d.setNeutralButton(Localization.get("option.no"), listener); showAlertDialog(d); }
Example 18
Source File: MainActivity.java From syncthing-android with Mozilla Public License 2.0 | 5 votes |
/** * Displays dialog asking user to accept/deny usage reporting. */ private void showUsageReportingDialog(RestApi restApi) { final DialogInterface.OnClickListener listener = (dialog, which) -> { try { switch (which) { case DialogInterface.BUTTON_POSITIVE: restApi.setUsageReporting(true); restApi.saveConfigAndRestart(); break; case DialogInterface.BUTTON_NEGATIVE: restApi.setUsageReporting(false); restApi.saveConfigAndRestart(); break; case DialogInterface.BUTTON_NEUTRAL: Uri uri = Uri.parse("https://data.syncthing.net"); startActivity(new Intent(Intent.ACTION_VIEW, uri)); break; } } catch (Exception e) { Log.e(TAG, "showUsageReportingDialog:OnClickListener", e); } }; restApi.getUsageReport(report -> { @SuppressLint("InflateParams") View v = LayoutInflater.from(MainActivity.this) .inflate(R.layout.dialog_usage_reporting, null); TextView tv = v.findViewById(R.id.example); tv.setText(report); Util.getAlertDialogBuilder(MainActivity.this) .setTitle(R.string.usage_reporting_dialog_title) .setView(v) .setPositiveButton(R.string.yes, listener) .setNegativeButton(R.string.no, listener) .setNeutralButton(R.string.open_website, listener) .show(); }); }
Example 19
Source File: MLAlertController.java From NewXmPluginSDK with Apache License 2.0 | 5 votes |
public Button getButton(int whichButton) { switch (whichButton) { case DialogInterface.BUTTON_POSITIVE: return mButtonPositive; case DialogInterface.BUTTON_NEGATIVE: return mButtonNegative; case DialogInterface.BUTTON_NEUTRAL: return mButtonNeutral; default: return null; } }
Example 20
Source File: ResetEditPreferenceDialogFragCompat.java From XposedSmsCode with GNU General Public License v3.0 | 4 votes |
public ResetEditPreferenceDialogFragCompat() { mWhichClicked = DialogInterface.BUTTON_NEUTRAL; }