DatePickerDialog 的监听
new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Year = year; month = monthOfYear + 1; day =dayOfMonth; setTitle(Year + "-" + month + "-" + day + "-" + hour + ":" + Minute); } }, Year, cal.get(Calendar.MONTH), day).show();
TimePickerDialog 的监听
new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { hour = hourOfDay; Minute = minute; setTitle(Year + "-" + month + "-" + day + "-" + hour + ":" + Minute); } }, hour, Minute,true).show();