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();
}
版权声明:本文为博主原创文章,欢迎转载,转载请在文章显眼处说明文章出处并给出连接。
时间: 2024-10-14 06:50:22