I am using material Date
Time
picker for my Android app. But I want to combine the Date
and Time
picker in one dialog.
If you need to select the time right after the date selection you can simply show TimePickerDialog
automatically after date is selected. This is the easiest way.
While you have listener that is fired when date is selected with selected date, you can simply pass that selected date to TimePickerDialog
and with a few customization in mdtp_time_picker_dialog.xml
you can add a TextView
to show the selected text.
Another option is merging mdtp_time_picker_dialog.xml
and mdtp_date_picker_dialog.xml
that are root layouts for date picker dialog and time picker dialog. You can set time picker part visibility as GONE
and switch the visibility when you want to switch pickers.
The second solution is more difficult to implement because in addition to layouts, you have to merge all controls and listeners.
If you want the user to see both of the pickers, I think you actually need to design a new view yourself. That library layouts is not suitable for this.