Skip to content Skip to sidebar Skip to footer

Setting Custom Date In DatePicker

Is there possibility to set a custom date in DatePicker? I want to set a date in DatePicker, and then allow user to edit it. Thanks!

Solution 1:

There's the DatePicker.init where you can set it...

Or to set the date you can use the calendar control as shown in the android developer sample. See Steps 4-6.

Here's another sample blog post on this.


Solution 2:

Have you seen this tutorial? It says to set the DatePicker initially, use DatePicker.init:

Calendar cal=Calendar.getInstance(Locale.ENGLISH);
dp.init(cal.getTime().getYear()+1900, cal.getTime().getMonth(), cal.getTime().getDay(), this);

Solution 3:

final Calendar c = Calendar.getInstance(Locale.ENGLISH);

    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);
    showDialog(DATE_DIALOG_ID);

Post a Comment for "Setting Custom Date In DatePicker"