The
TimePicker
we saw
here
takes a lot of screen space.
You might want to pop up a
TimePickerDialog
instead.
It takes the same amount of space,
but, like any
Dialog,
it remains visible for only a short time.
(A
Dialog
is the Android equivalent of an iPhone
UIActionSheet
or a view managed by a
modal
view controller.)
See the time picker dialog
tutorial.
This app creates only one dialog,
although it can pop up again and again.
A more complicated app might create several different dialogs.
Each dialog therefore has its own id number, e.g.,
TIME_PICKER_DIALOG_ID
.
For each dialog,
the
onCreateDialog
method of the
Activity
is called only once,
to create the dialog.
The
onPrepareDialog
method is called each time the dialog is popped up.
Do not call these methods yourself—they’re called automatically
when you call
showDialog
.
The cancel button does not call
onCancel
.
TimePickerDialog
.
Calls
onTimeSet
and
onDismiss
.TimePickerDialog
.
Calls
onDismiss
.onCancel
and
onDismiss
.onDismiss
and the dialog reappears in the new orientation.
The
setText
method of the activity formats the time in 12- or 24-hour format,
depending on the setting set by the Android Settings app.
Warning:
the
getTimeFormat
method of class
android.text.format.DateFormat
java.text.DateFormat
.DateFormat
s
are two different classes.
TimePicker
reflect this change?TimePickerDialog
?
TIME_PICKER_DIALOG_ID
)
be a set of Java enums?