标签:
TimePickerView pvTime = new TimePickerView(context, TimePickerView.Type.YEAR_MONTH_DAY); pvTime.setTime(Time.nowDate()); pvTime.setCancelable(true); pvTime.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() { public void onTimeSelect(Date date) { MyToast.showInfo(Time.date2StrYM(date), context); MyToast.showInfo(Time.date2StrYMD(date), context); } }); pvTime.show();
复杂
private TimePickerView pvTime;
pvTime = new TimePickerView(context, TimePickerView.Type.YEAR_MONTH_DAY); pvTime.setCancelable(true); pvTime.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() { public void onTimeSelect(Date date) { //选择日期早于now if (date.getTime() <= new Date().getTime()) txtDate.setText(Time.date2StrYMD(date)); else MyToast.showInfo("血压记录: 日期不得迟于今天", context); } });
//每次点击时间选择: 内置时间都会从Textview中读取 pvTime.setTime(Time.str2Date(txtDate.getText().toString())); pvTime.show();
标签:
原文地址:http://www.cnblogs.com/guixianfeng/p/5105556.html