Subcategory: Form Design
Android Platform: 1.5, Google APIs 3
Referenced Classes: android.app.DatePickerDialog, android.app.DatePickerDialog.OnDateSetListener, android.app.TimePickerDialog
I wanted a user-friendly way to specify both date and time with a minimum number of clicks. After considering suggestions I had found in the following thread (http://groups.google.com/group/android-developers/browse_thread/thread/de5f380c370e6410/a312e14b2fe8d915?lnk=gst&q=date+picker+dialog+load+time#a312e14b2fe8d915), I decided to show the DatePickerDialog and TimePickerDialog in sequence. I did this by using DatePickerDialog.OnDateSetListener:
code snippet
private DatePickerDialog datePickerDialog= ...
private TimePickerDialog timePickerDialog= ...
private Calendar currentTime= ...
public void onDateSet(DatePicker view,
int year, int monthOfYear, int dayOfMonth)
{
// dismiss DatePickerDialog, then show TimePickerDialog
this.datePickerDialog.dismiss();
this.timePickerDialog.updateTime(
this.currentTime.get(Calendar.HOUR_OF_DAY),
this.currentTime.get(Calendar.MINUTE));
this.timePickerDialog.show();
}
No comments:
Post a Comment