- 源代码未附上,需要的请私密我...
- 一般使用方法
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();
时间: 2024-10-06 04:54:57