timepicker android,TimePicker Android

管梓
2023-12-01

What you need is to save the data that you want in some variables to use later.

Android has the TimePickerDialog and DatePickerDialog that you can use:

// the callback received when the user "sets" the date in the dialog

private DatePickerDialog.OnDateSetListener mDateSetListener =

new DatePickerDialog.OnDateSetListener() {

public void onDateSet(DatePicker view, int year,

int monthOfYear, int dayOfMonth) {

mYear = year;

mMonth = monthOfYear;

mDay = dayOfMonth;

updateDisplay();

}

};

// the callback received when the user "sets" the time in the dialog

private TimePickerDialog.OnTimeSetListener mTimeSetListener =

new TimePickerDialog.OnTimeSetListener() {

public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

mHour = hourOfDay;

mMinute = minute;

updateDisplay();

}

};

Do not forget that if you want to use the two dialogs you will need to have a different id for each one.

 类似资料:

相关阅读

相关文章

相关问答