我如何设置日期选择器的日期? [英] How do I set the date for a date picker?
本文介绍了我如何设置日期选择器的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用 DatePickerDialog.OnDateSetListener
这是正常工作。
我要在日期选择器添加日期为120天。
I want to add date for 120 days in date picker.
我的意思是,如果我加上120天,日期和月份会自动更改。
怎么办呢?
What I mean is if I add 120 days, the date and month will be change automatically. How to do it?
推荐答案
这样的事情应该做的伎俩:
Something like this should do the trick:
Calendar cal = Calendar.getInstance();
cal.set(datepick.getYear(), datepick.getMonth() + 1, datepick.getDayOfMonth());
cal.add(Calendar.DATE, 120);
datepick.updateDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) - 1, cal.get(Calendar.DATE));
这篇关于我如何设置日期选择器的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文