avast / android-styled-dialogs

Backport of Material dialogs with easy-to-use API based on DialogFragment
Apache License 2.0
2.15k stars 450 forks source link

Custom Dialog SimpleDialogFragment Extension doesn't work? #72

Closed Gaudon closed 10 years ago

Gaudon commented 10 years ago

In the demo app, there is an example of a custom dialog by extending SimpleDialogFragment and specifying a new layout in the .setView() method.

In my experience, setting the builder.setView() to a custom layout .xml file has no effect, and the dialog simple shows up as a neutral close button (no title, body, custom layout elements, etc).

My use case is pretty straight forward:

public class CancelDialog extends SimpleDialogFragment {

    public static String TAG = "CancelDialog";

    public static void show(FragmentActivity activity) {
        new CancelDialog().show(activity.getSupportFragmentManager(), TAG);
    }

    @Override
    public BaseDialogFragment.Builder build(BaseDialogFragment.Builder builder) {
        builder.setTitle(R.string.cancel_dialog_title);
        builder.setView(LayoutInflater.from(getActivity()).inflate(R.layout.dialog_cancel, null));
        builder.setIcon(R.drawable.ic_action_discard);
        return builder;
    }
}

Use case:

CancelDialog.createBuilder(getActivity(), getActivity().getSupportFragmentManager()).setRequestCode(CANCEL_DIALOG).show();

The layout XML is a linear layout (vertical) with 2 TextViews and an input EditText.

What am I missing here?

Gaudon commented 10 years ago

I figured it out, disregard.