The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
DatePicker, as the name might suggest, allows the user to pick a date.
You supply a starting date, which the user then manipulates, triggering
event listeners whenever the date is changed.
If you do nothing, the
DatePicker will start with today’s date.
However, if you want to set up an
OnDateSetListener to find out when
the date changes, you will need to call
init() to do so, in which
you also need to set the date.
DatePicker works well with
terms of setting and getting the year/month/day-of-month from the
DatePicker and converting it into something you can use in your code.
API Level 11 introduced an optional
CalendarView adjunct to the
DatePicker, determined via
android:calendarViewShown. This works well on
-normal screens in
landscape and on
-xlarge screens. On
in portrait, the year portion of the picker may be chopped off
to save room. Using the
CalendarView option on
is probably not a good idea.
However, on Android 5.0+, the
CalendarView is always shown and
cannot be removed, as the “picker” itself does not allow the user to
pick a date. The user uses the
CalendarView to pick a date, or taps
on the year in the “picker” to choose a year. This means that
is not a particularly good widget to use, especially on smaller
The preview of this section is en route to Mars.
The preview of this section apparently resembled a Pokémon.