-3

How to implement date picker dialog like the one in the image below.

Thanks in advanceenter image description here

3 Answers3

1
public static class TimePickerFragment extends DialogFragment
                            implements TimePickerDialog.OnTimeSetListener {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the current time as the default values for the picker
        final Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);

        // Create a new instance of TimePickerDialog and return it
        return new TimePickerDialog(getActivity(), this, hour, minute,
                DateFormat.is24HourFormat(getActivity()));
    }

    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        // Do something with the time chosen by the user
    }

To show time picker,

   public void showTimePickerDialog(View v) {
    DialogFragment newFragment = new TimePickerFragment();
    newFragment.show(getSupportFragmentManager(), "timePicker");
}
Silvans Solanki
  • 1,267
  • 1
  • 14
  • 27
1

It depends on you SDK version. If you really need the same look on older versions of Android, you can use this library. I've used it before and it is awesome! It requires API 14 (Ice Cream Sandwich)
https://github.com/wdullaer/MaterialDateTimePicker

It might also be worth checking out this library:
https://github.com/vikramkakkar/SublimePicker

0

Depends of your min. SDK! If you have 5.0 or more, this version have it as normal component, but if you have less version then you need to use a external library. You can find this libraries, for example here or here.

Tell me if I helps you and good programming!