D
D
Dmitry Serkov2016-10-01 11:51:20
Android
Dmitry Serkov, 2016-10-01 11:51:20

Can buttons be controlled?

There is CustomDialogFragment extends AppCompatDialogFragment
in it I define two buttons:

AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
builder
     .setView(customDialog)
     .setPositiveButton(android.R.string.ok, this)
     .setNegativeButton(android.R.string.cancel, null)
     .create());

Is it possible to control button activity?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2016-10-01
@Hutaab

Can.

AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
AlertDialog dialog = builder
     .setView(customDialog)
     .setPositiveButton(android.R.string.ok, this)
     .setNegativeButton(android.R.string.cancel, null)
     .create());
dialog.setOnShowListener(dialogInterface ->
                    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(view -> {
                            // тут код
                            dialog.dismiss();
                        }
                    }));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question