TimePickerDialog
Android的DatePickerDiaolog是弹出时间管理的窗口,DatePickerDiaolog描述的年月日时间;,与TimePickerDiaolog不同的是TimePickerDiaolog描述的是一天中具体的时分,TimePickerDiaolog有两中表示方式,一种是12小时制,一种是24小时制。
private Calendar mCalendar;
private Button mButtonTimePickerDialog;
private void showTimePickerDialog() {
mCalendar = Calendar.getInstance();
TimePickerDialog dialog = new TimePickerDialog(DialogActivity.this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int i, int i1) {
mCalendar.set(Calendar.HOUR, i);
mCalendar.set(Calendar.MINUTE, i1);
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日HH:mm");
Toast.makeText(getApplicationContext(), "" + format.format(mCalendar.getTime()), Toast.LENGTH_SHORT).show();
}
}, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), true);
dialog.show();
}