O
O
omuradill2016-03-02 13:53:23
Java
omuradill, 2016-03-02 13:53:23

How to remove buttons from dialog box?

I use the MaterialDateTimePicker library and there are two buttons Ok and Cancel in the window. That is, you choose a date and then you have to click on OK! So I need to remove these buttons and when choosing a date, I immediately went. I rummaged everywhere, but could not understand because everywhere it refers back and forth. I am new to this business and I have a mess in my head ... Please help me, where to dig, where to look?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2016-03-02
@omuradill

Judging by the code, the authors do not provide for this. You can do this hack:
inherit your dialog from DatePickerDialog, override:

public View onCreateView(...) {
    final View root = super.onCreateView(...);
    root.findViewById(com.wdullaer.materialdatetimepicker.R.id.ok).setVisibility(View.GONE);
    root.findViewById(com.wdullaer.materialdatetimepicker.R.id.cancel).setVisibility(View.GONE);
    return root;
}

And add the use of autoDismiss as suggested by razer89 .
But, in fact, from a usability point of view, this is bad.

R
razer89, 2016-03-02
@razer89

From the library documentation:
Try setting this parameter to true. Not the fact that the buttons will disappear, but the dialog should start hiding after the date is selected

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question