设置时间和日期日期选取器和时间选择器在安卓 [英] Setting time and date to date picker and time picker in android

查看:152
本文介绍了设置时间和日期日期选取器和时间选择器在安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的日期选择器和时间选择器在我的应用程序。我想设置的日期和时间时,页面加载。这可能吗?怎么会这样?

I am using a date picker and time picker in my application. I want to set the date and time when the page loads. Is this possible? How so?

推荐答案

我解决了我的一个类似的问题如下:

I solved a similar problem of mine as follows

Calendar cal=Calendar.getInstance();

int year=cal.get(Calendar.YEAR);
int month=cal.get(Calendar.MONTH);
int day=cal.get(Calendar.DAY_OF_MONTH);
int hour=cal.get(Calendar.HOUR_OF_DAY);
int min=cal.get(Calendar.MINUTE);

datePicker.updateDate(year, month, day);

timePicker.setCurrentHour(hour);
timePicker.setCurrentMinute(min);

这篇关于设置时间和日期日期选取器和时间选择器在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆