【android】时间选择器
来源:程序员人生 发布时间:2015-04-21 08:58:05 阅读次数:4068次
OnDateSetListener listener = new OnDateSetListener() {
@Override
public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
String str = null;
String str1 = null;
if (arg2 < 10) {
arg2 = arg2 + 1;
str = "0" + arg2;
} else {
str = arg2 + "";
}
if (arg3 < 10) {
str1 = "0" + arg3;
} else {
str1 = arg3 + "";
}
t4.setText(arg1 + "-" + str + "-" + str1);
}
};
case R.id.textView4:
Calendar c1 = Calendar.getInstance();
int year = c1.get(Calendar.YEAR);
int monthOfYear = c1.get(Calendar.MONTH);
int dayOfMonth = c1.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog = new DatePickerDialog(ToRecordActivit.this,
listener, year, monthOfYear, dayOfMonth);
dialog.show();
break;
制止转载
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠