Code example for AlertDialog

Methods: getButton

        // 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() {
            public void onClick(View v) {
                mSeekBar.setProgress(mHw.getDefaultValue() - mMin);
    protected void onDialogClosed(boolean positiveResult) {
        if (positiveResult) {
            // Store HW value in SharedPreferences object 
Connect your IDE to all the code out there  Get Codota for Java