Sean Hill Sean Hill - 5 months ago 15
Android Question

If I make my own DialogFragment do I have to make my own buttons?

I notice that if I use a regular DialogFragment I can have the OK/Cancel buttons built into it.

But if I want to replace the body of the DialogFragment with something custom, I can't have the OK/Cancel buttons built-in; I have to add them myself.

But if I add them myself, now it's no longer the same formatting as the original.

Is there a way to recreate the same buttons as the built-ins?


Hey I'm using this library for material dialogs and its really great. So back to your question and this library: if you will use custom view you can keep buttons as well as create own. It's up to you to decide. This is example:

   MaterialDialog dialog = new MaterialDialog.Builder(this)
            .customView(R.layout.dialog_customview, true)
            .onPositive(new MaterialDialog.SingleButtonCallback() {
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    showToast("Password: " + passwordInput.getText().toString());