Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How create new "circle" datepicker android dialog

I want create a DatePicker like this:

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

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?

like image 521
Atlas91 Avatar asked May 19 '14 07:05

Atlas91


Video Answer


1 Answers

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

like image 91
david.schreiber Avatar answered Oct 26 '22 16:10

david.schreiber