Java Code Examples for android.app.AlertDialog#getButton()

The following examples show how to use android.app.AlertDialog#getButton() . 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: DisconnectVPNActivity.java    From Cybernet-VPN with GNU General Public License v3.0 6 votes vote down vote up
private void showDisconnectDialog()
{

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.title_cancel);
    builder.setMessage(R.string.cancel_connection_query);
    builder.setNegativeButton(android.R.string.no, this);
    builder.setPositiveButton(android.R.string.yes, this);
    builder.setOnCancelListener(this);
    builder.show();

    AlertDialog alert11 = builder.create();
    alert11.show();

    Button buttonbackground = alert11.getButton(DialogInterface.BUTTON_NEGATIVE);
    buttonbackground.setTextColor(Color.RED);

    Button buttonbackground1 = alert11.getButton(DialogInterface.BUTTON_POSITIVE);
    buttonbackground1.setTextColor(Color.RED);
}
 
Example 2
Source File: DownloadCustomCertDialogFragment.java    From moVirt with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    final AlertDialog dialog = (AlertDialog) getDialog();
    if (dialog != null) {
        Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setOnClickListener(v -> {
            try {
                URL url1 = URIUtils.tryToParseUrl(urlText.getText().toString());
                getListener().onNewDialogUrl(url1, startNewChain);
                dialog.dismiss();
            } catch (IllegalArgumentException parseError) {
                commonMessageHelper.showToast(parseError.getMessage());
            }
        });
    }
}
 
Example 3
Source File: KeyboardShortcutDialogPreference.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
protected void showDialog(Bundle state) {
  super.showDialog(state);
  AlertDialog alertDialog = (AlertDialog) getDialog();
  if (alertDialog == null) {
    return;
  }

  View clear = alertDialog.findViewById(R.id.clear);
  clear.setOnClickListener(clearButtonClickListener);
  alertDialog
      .getButton(DialogInterface.BUTTON_POSITIVE)
      .setOnClickListener(okButtonClickListener);
  alertDialog.setOnKeyListener(this);

  Button okButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
  okButton.setFocusableInTouchMode(true);
  okButton.requestFocus();

  setKeyEventSource(getKeyEventSourceForCurrentKeyComboModel());
}
 
Example 4
Source File: MeasurementView.java    From openScale with GNU General Public License v3.0 5 votes vote down vote up
private void prepareInputDialog(final AlertDialog dialog) {
    dialog.setTitle(getName());
    dialog.setIcon(getIcon());

    final View input = getInputView();

    FrameLayout fl = dialog.findViewById(android.R.id.custom);
    fl.removeAllViews();
    fl.addView(input, new LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    View.OnClickListener clickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (view == dialog.getButton(DialogInterface.BUTTON_POSITIVE)
                && !validateAndSetInput(input)) {
                return;
            }
            dialog.dismiss();
        }
    };

    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener);
    dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener(clickListener);

    final MeasurementView next = getNextView();
    if (next != null) {
        dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (validateAndSetInput(input)) {
                    next.prepareInputDialog(dialog);
                }
            }
        });
    }
    else {
        dialog.getButton(DialogInterface.BUTTON_NEUTRAL).setVisibility(GONE);
    }
}
 
Example 5
Source File: MakeCommentDialog.java    From Broadsheet.ie-Android with MIT License 5 votes vote down vote up
@Override
public void onStart() {
    spiceManager.start(getActivity());
    super.onStart();

    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setOnClickListener(this);
    }

    ((BroadsheetApplication) getActivity().getApplication()).getTracker().sendView("Post Comment");
}
 
Example 6
Source File: GpxExportDialogFragment.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public void onStart() {
    super.onStart();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setEnabled(false);
    }
    startExport();
}
 
Example 7
Source File: LoginDialogFragment.java    From Hews with MIT License 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    final AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String username;
                username = tiLayoutName.getEditText().getText().toString();
                String password;
                password = tiLayoutPassword.getEditText().getText().toString();
                if (Utils.isOnline(LoginDialogFragment.this.getActivity())) {
                    if (!username.isEmpty() && password.length() >= 6) {
                        mListener.onLogin(username, password);
                        tiLayoutName.setVisibility(View.GONE);
                        tiLayoutPassword.setVisibility(View.GONE);
                        progress.setVisibility(View.VISIBLE);
                        tvPrompt.setTextColor(getActivity().getResources().getColor(android.R.color.black));
                        tvPrompt.setText(R.string.login_prompt_logging_in);
                    } else if (username.isEmpty()) {
                        tvPrompt.setTextColor(getActivity().getResources().getColor(android.R.color.holo_red_dark));
                        tvPrompt.setText(R.string.login_prompt_error_empty_username);
                    } else if (password.length() < 6) {
                        // according to a user report, the password may less than 8 characters
                        tvPrompt.setTextColor(getActivity().getResources().getColor(android.R.color.holo_red_dark));
                        tvPrompt.setText(R.string.login_prompt_error_short_password);
                    }
                } else {
                    tvPrompt.setTextColor(getActivity().getResources().getColor(android.R.color.holo_red_dark));
                    tvPrompt.setText(R.string.login_prompt_error_offline);
                }
            }
        });
    }
}
 
Example 8
Source File: GpxImportDialogFragment.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public void onStart() {
    super.onStart();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setEnabled(false);
    }
    startImport();
}
 
Example 9
Source File: TipDialog.java    From Broadsheet.ie-Android with MIT License 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setOnClickListener(this);
    }

    ((BroadsheetApplication) getActivity().getApplication()).getTracker().sendView("Submit Tip");
}
 
Example 10
Source File: StageExportDialogFragment.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public void onStart() {
    super.onStart();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setEnabled(false);
    }
    startExport();
}
 
Example 11
Source File: LocationServicesDialogBoxModule.java    From react-native-android-location-services-dialog-box with MIT License 5 votes vote down vote up
private void colorAdjustment(AlertDialog dialog, ReadableMap colorMap) {
    Window window = dialog.getWindow();

    if (window != null) {
        Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
        Button negativeButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);

        if (colorMap.hasKey("backgroundColor")) {
            window.setBackgroundDrawable(new ColorDrawable(Color.parseColor(colorMap.getString("backgroundColor"))));
        }

        if (colorMap.hasKey("positiveButtonTextColor")) {
            positiveButton.setTextColor(Color.parseColor(colorMap.getString("positiveButtonTextColor")));
        }

        if (colorMap.hasKey("positiveButtonBackgroundColor")) {
            positiveButton.setBackgroundColor(Color.parseColor(colorMap.getString("positiveButtonBackgroundColor")));
        }

        if (colorMap.hasKey("negativeButtonTextColor")) {
            negativeButton.setTextColor(Color.parseColor(colorMap.getString("negativeButtonTextColor")));
        }

        if (colorMap.hasKey("negativeButtonBackgroundColor")) {
            negativeButton.setBackgroundColor(Color.parseColor(colorMap.getString("negativeButtonBackgroundColor")));
        }
    }
}
 
Example 12
Source File: KmzExportDialogFragment.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public void onStart() {
    super.onStart();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setEnabled(false);
    }
    startExport();
}
 
Example 13
Source File: EditTextPreferenceTEXT.java    From 600SeriesAndroidUploader with MIT License 5 votes vote down vote up
@Override
protected void showDialog(Bundle state) {
    super.showDialog(state);
    AlertDialog dlg = (AlertDialog) getDialog();
    View positiveButton = dlg.getButton(DialogInterface.BUTTON_POSITIVE);
    getEditText().setError(null);
    positiveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onPositiveButtonClicked(v);
        }
    });
}
 
Example 14
Source File: EditTextPreferenceURL.java    From 600SeriesAndroidUploader with MIT License 5 votes vote down vote up
@Override
protected void showDialog(Bundle state) {
    super.showDialog(state);
    AlertDialog dlg = (AlertDialog) getDialog();
    View positiveButton = dlg.getButton(DialogInterface.BUTTON_POSITIVE);
    getEditText().setError(null);
    positiveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onPositiveButtonClicked(v);
        }
    });
}
 
Example 15
Source File: EditTextPreferenceSECRET.java    From 600SeriesAndroidUploader with MIT License 5 votes vote down vote up
@Override
protected void showDialog(Bundle state) {
    super.showDialog(state);
    AlertDialog dlg = (AlertDialog) getDialog();
    View positiveButton = dlg.getButton(DialogInterface.BUTTON_POSITIVE);
    getEditText().setError(null);
    positiveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onPositiveButtonClicked(v);
        }
    });
}
 
Example 16
Source File: EditTextPreferencePUSHOVER.java    From 600SeriesAndroidUploader with MIT License 5 votes vote down vote up
@Override
protected void showDialog(Bundle state) {
    super.showDialog(state);
    AlertDialog dlg = (AlertDialog) getDialog();
    View positiveButton = dlg.getButton(DialogInterface.BUTTON_POSITIVE);
    getEditText().setError(null);
    positiveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onPositiveButtonClicked(v);
        }
    });
}
 
Example 17
Source File: EditTextPreferenceURCHIN.java    From 600SeriesAndroidUploader with MIT License 5 votes vote down vote up
@Override
protected void showDialog(Bundle state) {
    super.showDialog(state);
    AlertDialog dlg = (AlertDialog) getDialog();
    View positiveButton = dlg.getButton(DialogInterface.BUTTON_POSITIVE);
    getEditText().setError(null);
    positiveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onPositiveButtonClicked(v);
        }
    });
}
 
Example 18
Source File: PdfExportDialogFragment.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public void onStart() {
    super.onStart();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        positiveButton.setEnabled(false);
    }
    startExport();
}
 
Example 19
Source File: IRKitCreateVirtualDeviceDialogFragment.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
@Override
public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
    AlertDialog dialog = (AlertDialog) getDialog();
    Button btn = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
    btn.setEnabled(s.length() > 0);
}
 
Example 20
Source File: GroupNameDialogFragment.java    From smartcard-reader with GNU General Public License v3.0 4 votes vote down vote up
void updateOkButtonState(AlertDialog dialog, EditText editText) {
    final Button okButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
    okButton.setEnabled(!TextUtils.isEmpty(editText.getText().toString().trim()));
}