I want create a DatePicker like this:
possibily without using external libraries. For first, is it possible? Now i can create a simple DatePickerDialog in this way:
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 appears as normal Dialog and not as a "clock". Any idea?
You should look into the android-betterpickers library: https://github.com/derekbrameyer/android-betterpickers/
Another library that provides a port of this date and time picker dialogs: https://github.com/flavienlaurent/datetimepicker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With