How do I set the current date in a DatePicker?

后端 未结 6 2241
夕颜
夕颜 2020-12-09 09:23

I need to be able to choose date and time in my application It should either be done by using a dialog, or starting a new intent.

The way I have done it now, is that

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 10:05

    Try this:

    Calendar c = Calendar.getInstance();
    year = c.get(Calendar.YEAR);
    month = c.get(Calendar.MONTH);
    day = c.get(Calendar.DAY_OF_MONTH);     
    
    // set current date into datepicker
    datepicker.init(year, month, day, null);
    

提交回复
热议问题