android.content.DialogInterface#BUTTON_NEUTRAL源码实例Demo

下面列出了android.content.DialogInterface#BUTTON_NEUTRAL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BaseProject   文件: SimpleHintAndInputDialog.java
@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);
    }
}
 
源代码2 项目: MHViewer   文件: DownloadFragment.java
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();
}
 
@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;
    }
}
 
源代码4 项目: NewXmPluginSDK   文件: MLAlertController.java
/**
 * 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");
    }
}
 
源代码5 项目: Nimingban   文件: TypeSendFragment.java
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();
}
 
源代码6 项目: Indic-Keyboard   文件: AccountsSettingsFragment.java
@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;
    }
}
 
源代码7 项目: NewXmPluginSDK   文件: MLAlertController.java
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;
    }
}
 
源代码8 项目: syncthing-android   文件: MainActivity.java
/**
 * 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();
    });
}
 
源代码9 项目: commcare-android   文件: HomeScreenBaseActivity.java
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);
}
 
源代码10 项目: ticdesign   文件: AlertController.java
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;
    }
}
 
源代码11 项目: tapchat-android   文件: MemorizingActivity.java
@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);
	}
}
 
/**
 * 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();
    }
}
 
源代码13 项目: Yahala-Messenger   文件: MemorizingActivity.java
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);
}
 
源代码14 项目: ticdesign   文件: AlertController.java
/**
 * 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");
    }
}
 
源代码15 项目: ticdesign   文件: AlertController.java
@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();
    }
}
 
源代码16 项目: mongol-library   文件: MongolAlertDialog.java
@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();
    }
}
 
源代码17 项目: browser   文件: BrowserActivity.java
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();
}
 
源代码18 项目: browser   文件: BrowserActivity.java
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();
}
 
@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;
    }
}
 
public ResetEditPreferenceDialogFragCompat() {
    mWhichClicked = DialogInterface.BUTTON_NEUTRAL;
}