How to create new datepicker android dialogs

I want to create a DatePicker as follows:

http://3.bp.blogspot.com/-SK2ljlhHiCU/UaiEjF1lhGI/AAAAAAABJqs/0uWv7oMxdG4/s640/android-calendar-time-control-1.png

possible without using external libraries. First, is this possible? Now I can create a simple DatePickerDialog as follows:

public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { public EditText activity_edittext; public DatePickerFragment(EditText edit_text) { activity_edittext = edit_text; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); // Create a new instance of DatePickerDialog and return it return new DatePickerDialog(getActivity(), this, year, month, day); } @Override public void onDateSet(DatePicker view, int year, int month, int day) { activity_edittext.setText(String.valueOf(month + 1 ) + "/" + String.valueOf(day) + "/" + String.valueOf(year)); } } 

but it looks like a regular Dialog, not like a "clock." Any idea?

+6
source share
1 answer

You should study the android-bestpickers library: https://github.com/derekbrameyer/android-betterpickers/

Another library providing a dialog port for this date and time: https://github.com/flavienlaurent/datetimepicker

+5
source

Source: https://habr.com/ru/post/969500/


All Articles