AlertDialog getButton - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AlertDialog getButton method.

This code example shows how to use the following methods:getButton, getWindow
    } 
 
    @Override 
    public void onResume() { 
        super.onResume(); 
        mDialog.getWindow()
                .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        if (mQuickResponseEditText.length() == 0) {
            mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
        } 
    } 
 
    // implements TextWatcher 
    @Override 
    public void afterTextChanged(Editable s) {
            mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(s.length() > 0);
    } 
 
    // implements TextWatcher 
    @Override 
6
CodeRank
This code example shows how to use the following methods:getButton
         * @param ctx The current context 
         * @param dialog The dialog which apply the style 
         */ 
        @SuppressWarnings("deprecation") 
        public void setDialogStyle(Context ctx, AlertDialog dialog) {
            applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON1));
            applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON2));
            applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON3));
            applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON_NEGATIVE));
            applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON_NEUTRAL));
            applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON_POSITIVE));
        } 
 
        /** 
         * Method that apply the current style to a button 
         * 
         * @param ctx The current context 
         * @param button The button which apply the style 
         */ 
        private void applyButtonStyle(Context ctx, Button button) {
6
CodeRank
This code example shows how to use the following methods:getButton
 
    @Override 
    public void onResume() { 
        super.onResume(); 
        if (mOkButton == null) {
            mOkButton = mAlertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
            mOkButton.setEnabled(mDeviceNameEdited);    // Ok button enabled after user edits
        } 
        IntentFilter filter = new IntentFilter();
        filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        filter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
        getActivity().registerReceiver(mReceiver, filter);
    } 
 
    @Override 
    public void onPause() { 
        super.onPause(); 
        getActivity().unregisterReceiver(mReceiver);
    } 
 
6
CodeRank
This code example shows how to use the following methods:getButton
        super.showDialog(state);
 
        // Can't use onPrepareDialogBuilder for this as we want the dialog 
        // to be kept open on click 
        AlertDialog d = (AlertDialog) getDialog();
        Button defaultsButton = d.getButton(DialogInterface.BUTTON_NEUTRAL);
        defaultsButton.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View v) {
                mSeekBar.setProgress(mHw.getDefaultValue() - mMin);
            } 
        }); 
    } 
 
    @Override 
    protected void onDialogClosed(boolean positiveResult) {
        super.onDialogClosed(positiveResult);
 
        if (positiveResult) {
            // Store HW value in SharedPreferences object 
5
CodeRank
This code example shows how to use the following methods:getButton
 
    private void updateOkButtonState() { 
        if (mOkButton == null) {
            AlertDialog dialog = (AlertDialog) getDialog();
            if (dialog != null) {
                mOkButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            } 
        } 
 
        if (mOkButton != null) {
            mOkButton.setEnabled(mEditText.getText().length() != 0);
        } 
    } 
 
    @Override 
    public void onSaveInstanceState(Bundle state) {
        super.onSaveInstanceState(state);
 
        Bundle dialogState = new Bundle();
        dialogState.putCharSequence(STATE_NUMBER, mEditText.getText());
6
CodeRank
This code example shows how to use the following methods:getButton
            updateOkButtonState(dialog);
        } 
    } 
 
    private void updateOkButtonState(AlertDialog dialog) {
        Button okButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
        okButton.setEnabled(!TextUtils.isEmpty(mEdit.getText().toString().trim()));
    } 
 
    @Override 
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    } 
 
    @Override 
    public void onTextChanged(CharSequence s, int start, int before, int count) {
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getButton, getWindow
    } 
 
    @Override 
    public void onResume() { 
        super.onResume(); 
        mDialog.getWindow()
                .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        if (mQuickResponseEditText.length() == 0) {
            mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
        } 
    } 
 
    // implements TextWatcher 
    @Override 
    public void afterTextChanged(Editable s) {
            mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(s.length() > 0);
    } 
 
    // implements TextWatcher 
    @Override 
5
CodeRank
This code example shows how to use the following methods:getButton
        if (dialog != null) {
            //String url = s.toString(); 
            //dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled( 
            //        url.length() == 0 || url.equals("about:blank") || 
            //        Regex.WEB_URL_PATTERN.matcher(url).matches()); 
            dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(true);
        } 
    } 
 
    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {
    } 
 
    public void onTextChanged(CharSequence s, int start, int before, int count) {
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getButton
	{ 
		final boolean needsPassword = needsPassword();
		final boolean hasPassword = !passwordView.getText().toString().trim().isEmpty();
		final boolean hasFile = hasFile();
 
		final Button button = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
		button.setEnabled(hasFile && (!needsPassword || hasPassword));
	} 
 
	protected boolean hasFile() 
	{ 
		return true; 
	} 
 
	protected boolean needsPassword() 
	{ 
		return true; 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getButton
            } 
 
            @Override 
            public void afterTextChanged(Editable s) {
                if (mPositiveButton == null) {
                    mPositiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
                } 
                mPositiveButton.setEnabled(s.toString().trim().length() > 0);
            } 
        }); 
 
        return dialog;
    } 
} 
5
CodeRank

Related AlertDialog getButton Questions & Answers:

getButton Method Overview
Gets one of the buttons used in the dialog.
See Code Examples for other Android AlertDialog Methods: