0

I have created my dialog fragment as follows:

public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.MessageDialogStyle);
    final View layout = getActivity().getLayoutInflater().inflate(R.layout.dialog_layout, null);
    builder.setView(layout)
            .setTitle(R.string.dialog_text)
            .setPositiveButton(R.string.dialog_positive, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    EditText text = (EditText) layout.findViewById(R.id.message);
                    mListener.onDialogSave(text.getText().toString());
                }
            })
            .setNegativeButton(R.string.dialog_negative, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    MessageDialogFragment.this.getDialog().cancel();
                }
            });

    return builder.create();
    }

As you can see I have inflated a layout for the body of the dialog and set the positive and negative buttons through the builder. Therefore the layout that I have inflated stops before the buttons. Is there any way to create a textview on the same line as the positive and negative buttons but on the left hand side rather than the right? Thanks

kabeersvohra
  • 1,049
  • 1
  • 14
  • 31
  • 3
    There is also *setNeutralButton*, so you can have 3 buttons – Marko Jun 10 '15 at 21:47
  • This seems promising, it is in the correct place. Is there any way to disable it being clickable and to update its text programmatically? – kabeersvohra Jun 10 '15 at 21:50
  • 2
    Of course it is possible, take a look at this [stackoverflow question](http://stackoverflow.com/questions/8238952/how-to-disable-enable-dialog-negative-positive-buttons). – Marko Jun 10 '15 at 21:55
  • Thank you, I am having problems still though because I need to set the text of the button constantly in an ontextchanged listener (it is to be a character count for an edit text) but I keep getting resourcesnotfound exception when I am trying to perform dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setText(""); in the listener. Do you have any suggestions as to how to access this within a listener in the fragment? Thanks – kabeersvohra Jun 10 '15 at 22:21
  • Update your question with the latest code and i'll take a look. – Marko Jun 11 '15 at 09:17

0 Answers0