Setting custom date in DatePicker

十年热恋 提交于 2019-12-25 02:05:41

问题


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!


回答1:


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);



回答2:


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.




回答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);


来源:https://stackoverflow.com/questions/8279898/setting-custom-date-in-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!