Java Code Examples for android.app.AlertDialog.Builder#setNeutralButton()
The following examples show how to use
android.app.AlertDialog.Builder#setNeutralButton() .
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: KeySelectDialogPreference.java From Plumble with GNU General Public License v3.0 | 5 votes |
@Override protected void onPrepareDialogBuilder(Builder builder) { super.onPrepareDialogBuilder(builder); builder.setOnKeyListener(this); builder.setNeutralButton(R.string.reset_key, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { keyCode = 0; valueTextView.setText("No Key"); persistInt(keyCode); // Neutral is a 'negative' response to android, we save manually here. } }); }
Example 2
Source File: AddUserInfoDialogFragment.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); 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); } final Builder builder = new Builder(getActivity(), mTheme); final View contentView = LayoutInflater.from(getActivity()) .inflate(R.layout.layout_dialog_names, null); mFirstNameEditText = (EditText) contentView .findViewById(R.id.edittext_first_name); mLastNameEditText = (EditText) contentView .findViewById(R.id.edittext_last_name); builder.setView(contentView); if (mIconId != 0) { builder.setIcon(mIconId); } if (mTitleId != 0) { builder.setTitle(mTitleId); } 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 3
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 4
Source File: AddSingleEditTextDialogFragment.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); 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); } final Builder builder = new Builder(getActivity(), mTheme); final View contentView = LayoutInflater.from(getActivity()) .inflate(R.layout.layout_dialog_place, null); mNameEditText = (EditText) contentView .findViewById(R.id.edittext_location_name); if(mHintLabelId!=0) { mNameEditText.setHint(mHintLabelId); } builder.setView(contentView); if (mIconId != 0) { builder.setIcon(mIconId); } if (mTitleId != 0) { builder.setTitle(mTitleId); } 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 5
Source File: EnableLocationDialogFragment.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 (mMessageId != 0) { if ((mMessageParams != null) && (mMessageParams.length > 0)) { builder.setMessage(getActivity() .getString(mMessageId, (Object[]) mMessageParams)); } else { builder.setMessage(mMessageId); } } if (mIconId != 0) { builder.setIcon(mIconId); } if (mTitleId != 0) { builder.setTitle(mTitleId); } 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 6
Source File: UpdaterDialogManager.java From TurkcellUpdater_android_sdk with Apache License 2.0 | 4 votes |
private static void initializeMessageDialogButtons(final Activity activity, Builder builder, final Message message) { final boolean viewButtonTargetGooglePlay; boolean viewButtonEnabled = false; if (message != null) { if (message.targetGooglePlay && !Utilities.isNullOrEmpty(message.targetPackageName)) { viewButtonTargetGooglePlay = true; viewButtonEnabled = true; } else if (message.targetWebsiteUrl != null) { viewButtonEnabled = true; viewButtonTargetGooglePlay = false; } else { viewButtonTargetGooglePlay = false; } } else { viewButtonTargetGooglePlay = false; } if (!viewButtonEnabled) { if (message.description != null && message.description.get(MessageDescription.KEY_POSITIVE_BUTTON) != null) { builder.setNeutralButton(message.description.get(MessageDescription.KEY_POSITIVE_BUTTON), null); } else { builder.setNeutralButton(R.string.close, null); } } else { if (message.description != null && message.description.get(MessageDescription.KEY_NEGATIVE_BUTTON) != null) { builder.setNegativeButton(message.description.get(MessageDescription.KEY_NEGATIVE_BUTTON), null); } else { builder.setNegativeButton(R.string.close, null); } OnClickListener onClickListener = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (viewButtonTargetGooglePlay) { openGooglePlayPage(activity, message.targetPackageName); } else { openWebPage(activity, message.targetWebsiteUrl); } } }; if (message.description != null && message.description.get(MessageDescription.KEY_POSITIVE_BUTTON) != null) { builder.setPositiveButton(message.description.get(MessageDescription.KEY_POSITIVE_BUTTON), onClickListener); } else { builder.setPositiveButton(R.string.view, onClickListener); } } }