Java Code Examples for android.app.AlertDialog.Builder#setNegativeButton()

The following examples show how to use android.app.AlertDialog.Builder#setNegativeButton() . 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: LogsFragment.java    From callmeter with GNU General Public License v3.0 8 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean onItemLongClick(final AdapterView<?> parent, final View view,
        final int position, final long id) {
    final Builder b = new Builder(getActivity());
    b.setCancelable(true);
    b.setItems(R.array.dialog_delete, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            LogsFragment.this
                    .getActivity()
                    .getContentResolver()
                    .delete(ContentUris.withAppendedId(DataProvider.Logs.CONTENT_URI, id),
                            null, null);
            LogsFragment.this.setAdapter(true);
            LogRunnerService.update(LogsFragment.this.getActivity(), null);
        }
    });
    b.setNegativeButton(android.R.string.cancel, null);
    b.show();
    return true;
}
 
Example 2
Source File: Main.java    From screenstandby with GNU General Public License v2.0 8 votes vote down vote up
private void openVideoClip()
  {
  	Builder watchDialog = new AlertDialog.Builder(this).setCancelable(true);
watchDialog.setTitle("Select a video clip:");
watchDialog.setIcon(android.R.drawable.ic_menu_slideshow);
watchDialog.setItems(clipsName, new android.content.DialogInterface.OnClickListener() {
	@Override
	public void onClick(DialogInterface dialog, int which) {
		if (which >= 0) {
			Intent youtubeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + clipsUrl[which]));
           	youtubeIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
           	startActivity(youtubeIntent);							
		}
	}});
watchDialog.setNegativeButton("Dismiss", null);
watchDialog.show();
  }
 
Example 3
Source File: CustomedDialog.java    From evercam-android with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * The prompt dialog that ask for a preset name
 */
public static AlertDialog getCreatePresetDialog(final VideoActivity videoActivity, final String cameraId) {
    Builder dialogBuilder = new AlertDialog.Builder(videoActivity);
    LayoutInflater inflater = LayoutInflater.from(videoActivity);
    final View view = inflater.inflate(R.layout.dialog_create_preset, null);
    final EditText editText = (EditText) view.findViewById(R.id.create_preset_edit_text);
    dialogBuilder.setView(view);
    dialogBuilder.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String presetName = editText.getText().toString();
            if (!presetName.isEmpty()) {
                new CreatePresetTask(videoActivity, cameraId, presetName)
                        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            }
        }
    });
    dialogBuilder.setNegativeButton(R.string.cancel, null);
    return dialogBuilder.create();
}
 
Example 4
Source File: MMAlert.java    From wechatsdk-xamarin with Apache License 2.0 6 votes vote down vote up
public static AlertDialog showAlert(final Context context, final String title, final String msg, final View view, final DialogInterface.OnClickListener lOk,
		final DialogInterface.OnClickListener lCancel) {
	if (context instanceof Activity && ((Activity) context).isFinishing()) {
		return null;
	}

	final Builder builder = new AlertDialog.Builder(context);
	builder.setTitle(title);
	builder.setMessage(msg);
	builder.setView(view);
	builder.setPositiveButton(R.string.app_ok, lOk);
	builder.setNegativeButton(R.string.app_cancel, lCancel);
	// builder.setCancelable(true);
	builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

		@Override
		public void onCancel(DialogInterface dialog) {
			if (lCancel != null) {
				lCancel.onClick(dialog, 0);
			}
		}
	});
	final AlertDialog alert = builder.create();
	alert.show();
	return alert;
}
 
Example 5
Source File: Utils.java    From BatteryFu with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Prompt user whether to proceed or not, if so, execute runnable
 * 
 * @param context
 * @param titleResId
 * @param msgResId
 * @param onConfirm
 */
public static void confirm(Context context, String logTag, int titleResId, int msgResId,
         int OkResId, int cancelResId, final Runnable onConfirm) {
   AlertDialog dialog = null;
   try {
      Builder b = new Builder(context);
      b.setCancelable(true);
      if (titleResId >= 0) b.setTitle(titleResId);
      if (msgResId >= 0) b.setMessage(msgResId);
      if (cancelResId >= 0) b.setNegativeButton(cancelResId, null);
      if (onConfirm != null && OkResId >= 0) b.setPositiveButton(OkResId, new OnClickListener() {
         @Override
         public void onClick(DialogInterface arg0, int arg1) {
            onConfirm.run();
         }
      });

      b.create().show();
   } catch (Exception e) {
      if (logTag != null) Utils.handleException(logTag, context, e);
   }
}
 
Example 6
Source File: NumberGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
        case R.id.item_add:
            showNumberDialog(-1);
            return true;
        case R.id.item_delete:
            Builder b = new Builder(this);
            b.setTitle(R.string.delete_group_);
            b.setMessage(R.string.delete_group_hint);
            b.setNegativeButton(android.R.string.no, null);
            b.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    NumberGroupEdit.this.getContentResolver().delete(
                            ContentUris.withAppendedId(DataProvider.NumbersGroup.CONTENT_URI,
                                    NumberGroupEdit.this.gid), null, null);
                    Preferences.setDefaultPlan(NumberGroupEdit.this, false);
                    RuleMatcher.unmatch(NumberGroupEdit.this);
                    NumberGroupEdit.this.finish();
                }
            });
            b.show();
            return true;
        case R.id.item_rename:
            showNameDialog();
            return true;
        case R.id.item_help:
            showHelp(R.string.numbergroup_help);
            return true;
        default:
            return false;
    }
}
 
Example 7
Source File: AlertExampleActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Dialog onCreateDialog(int id) {
	switch (id) {
	case DIALOG_ALERT:
		// Create out AlterDialog
		Builder builder = new AlertDialog.Builder(this);
		builder.setMessage("This will end the activity");
		builder.setCancelable(true);
		builder.setPositiveButton("I agree", new OkOnClickListener());
		builder.setNegativeButton("No, no", new CancelOnClickListener());
		AlertDialog dialog = builder.create();
		dialog.show();
	}
	return super.onCreateDialog(id);
}
 
Example 8
Source File: MyOverlays.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean onTap(int index) {
	OverlayItem overlayItem = overlays[index];
	Builder builder = new AlertDialog.Builder(context);
	builder.setMessage("This will end the activity");
	builder.setCancelable(true);
	builder.setPositiveButton("I agree", new OkOnClickListener());
	builder.setNegativeButton("No, no", new CancelOnClickListener());
	AlertDialog dialog = builder.create();
	dialog.show();
	return true;
}
 
Example 9
Source File: HourGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Show dialog to edit the group name.
 */
private void showNameDialog() {
    final Uri u = ContentUris.withAppendedId(DataProvider.HoursGroup.CONTENT_URI, gid);
    Cursor c = getContentResolver().query(u, DataProvider.HoursGroup.PROJECTION, null,
            null, null);
    String name = null;
    if (c.moveToFirst()) {
        name = c.getString(DataProvider.NumbersGroup.INDEX_NAME);
    }
    c.close();
    final Builder builder = new Builder(this);
    final EditText et = new EditText(this);
    et.setText(name);
    builder.setView(et);
    builder.setTitle(R.string.name_);
    builder.setCancelable(true);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(final DialogInterface dialog, final int id) {
            ContentValues values = new ContentValues();
            values.put(DataProvider.NumbersGroup.NAME, et.getText().toString());
            HourGroupEdit.this.getContentResolver().update(u, values, null, null);
            CallMeter.setActivitySubtitle(HourGroupEdit.this, et.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.show();
}
 
Example 10
Source File: NumberGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(final Preference preference) {
    String k = preference.getKey();
    if (k != null && k.startsWith("item_")) {
        final long id = Long.parseLong(k.substring("item_".length()));

        final Builder builder = new Builder(this);
        builder.setItems(R.array.dialog_edit_delete,
                new android.content.DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        switch (which) {
                            case WHICH_EDIT:
                                NumberGroupEdit.this.showNumberDialog(id);
                                break;
                            case WHICH_DELETE:
                                NumberGroupEdit.this.getContentResolver().delete(
                                        ContentUris.withAppendedId(
                                                DataProvider.Numbers.CONTENT_URI, id), null,
                                        null);
                                NumberGroupEdit.this.reload();
                                RuleMatcher.unmatch(NumberGroupEdit.this);
                                break;
                            default:
                                break;
                        }
                    }
                });
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.show();
    }

    return false;
}
 
Example 11
Source File: HourGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
        case R.id.item_add:
            showHourDialog(-1);
            return true;
        case R.id.item_delete:
            Builder b = new Builder(this);
            b.setTitle(R.string.delete_group_);
            b.setMessage(R.string.delete_group_hint);
            b.setNegativeButton(android.R.string.no, null);
            b.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    HourGroupEdit.this.getContentResolver().delete(
                            ContentUris.withAppendedId(DataProvider.HoursGroup.CONTENT_URI,
                                    HourGroupEdit.this.gid), null, null);
                    Preferences.setDefaultPlan(HourGroupEdit.this, false);
                    RuleMatcher.unmatch(HourGroupEdit.this);
                    HourGroupEdit.this.finish();
                }
            });
            b.show();
            return true;
        case R.id.item_rename:
            showNameDialog();
            return true;
        case R.id.item_help:
            showHelp(R.string.hourgroup_help);
            return true;
        default:
            return false;
    }
}
 
Example 12
Source File: NumberGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Show dialog to edit the group name.
 */
private void showNameDialog() {
    final Uri u = ContentUris.withAppendedId(DataProvider.NumbersGroup.CONTENT_URI, gid);
    Cursor c = getContentResolver().query(u, DataProvider.NumbersGroup.PROJECTION, null,
            null, null);
    String name = null;
    if (c.moveToFirst()) {
        name = c.getString(DataProvider.NumbersGroup.INDEX_NAME);
    }
    c.close();
    final Builder builder = new Builder(this);
    final EditText et = new EditText(this);
    et.setText(name);
    builder.setView(et);
    builder.setTitle(R.string.name_);
    builder.setCancelable(true);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(final DialogInterface dialog, final int id) {
            ContentValues values = new ContentValues();
            values.put(DataProvider.NumbersGroup.NAME, et.getText().toString());
            NumberGroupEdit.this.getContentResolver().update(u, values, null, null);
            CallMeter.setActivitySubtitle(NumberGroupEdit.this, et.getText().toString());
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.show();
}
 
Example 13
Source File: HourGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceClick(final Preference preference) {
    String k = preference.getKey();
    if (k != null && k.startsWith("item_")) {
        final long id = Long.parseLong(k.substring("item_".length()));

        final Builder builder = new Builder(this);
        builder.setItems(R.array.dialog_edit_delete,
                new android.content.DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        switch (which) {
                            case WHICH_EDIT:
                                HourGroupEdit.this.showHourDialog(id);
                                break;
                            case WHICH_DELETE:
                                HourGroupEdit.this.getContentResolver().delete(
                                        ContentUris
                                                .withAppendedId(DataProvider.Hours.CONTENT_URI,
                                                        id), null, null);
                                HourGroupEdit.this.reload();
                                RuleMatcher.unmatch(HourGroupEdit.this);
                                break;
                            default:
                                break;
                        }
                    }
                });
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.show();
    }
    return false;
}
 
Example 14
Source File: BillModeListPreference.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onDialogClosed(final boolean positiveResult) {
    final String ov = getValue();
    super.onDialogClosed(positiveResult);
    if (positiveResult) {
        String v = getValue();
        if (v == null || !v.contains("/")) { // custom bill mode
            Builder b = new Builder(getContext());
            final EditText et = new EditText(getContext());
            et.setText(ov);
            b.setView(et);
            b.setCancelable(false);
            b.setTitle(getTitle());
            b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface paramDialogInterface,
                        final int paramInt) {
                    BillModeListPreference.this.setValue(ov);
                }
            });
            b.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    String nv = et.getText().toString().trim();
                    final String[] t = nv.toString().split("/");
                    if (t.length != 2 || !TextUtils.isDigitsOnly(t[0])
                            || !TextUtils.isDigitsOnly(t[1])) {
                        Toast.makeText(BillModeListPreference.this.ctx, R.string.missing_slash,
                                Toast.LENGTH_LONG).show();
                        BillModeListPreference.this.setValue(ov);
                    } else {
                        BillModeListPreference.this.setValue(nv);
                    }
                }
            });
            b.show();
        }
    }
}
 
Example 15
Source File: PlansFragment.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean onItemLongClick(final AdapterView<?> parent, final View view,
        final int position, final long id) {
    final Builder builder = new Builder(getActivity());
    builder.setItems(R.array.dialog_edit_plan,
            new android.content.DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    switch (which) {
                        case 0:
                            Intent intent = new Intent(PlansFragment.this.getActivity(),
                                    PlanEdit.class);
                            intent.setData(ContentUris.withAppendedId(
                                    DataProvider.Plans.CONTENT_URI, id));
                            PlansFragment.this.getActivity().startActivity(intent);
                            break;
                        case 1:
                            ((Plans) PlansFragment.this.getActivity()).showLogsFragment(id);
                            break;
                        default:
                            break;
                    }
                }
            });
    builder.setNegativeButton(android.R.string.cancel, null);
    builder.show();
    return true;
}
 
Example 16
Source File: UpdaterDialogManager.java    From TurkcellUpdater_android_sdk with Apache License 2.0 4 votes vote down vote up
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);
        }
    }
}
 
Example 17
Source File: AlertDialogFragment.java    From barterli_android with Apache License 2.0 4 votes vote down vote up
@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 18
Source File: AddSingleEditTextDialogFragment.java    From barterli_android with Apache License 2.0 4 votes vote down vote up
@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 19
Source File: EnableLocationDialogFragment.java    From barterli_android with Apache License 2.0 4 votes vote down vote up
@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 20
Source File: SettingsActivity.java    From qBittorrent-Controller with MIT License 3 votes vote down vote up
private void genericOkCancelDialog(int title, int message, DialogInterface.OnClickListener okListener) {

        if (!isFinishing()) {

            Builder builder = new Builder(this);

            // Title
            if (title != -1) {
                builder.setTitle(title);
            }

            // Message
            builder.setMessage(message);

            // Ok
            builder.setPositiveButton(R.string.ok, okListener);

            // Cancel
            builder.setNegativeButton(R.string.cancel, null);

            // Create dialog
            AlertDialog dialog = builder.create();

            // Show dialog
            dialog.show();
        }

    }