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.

Widget Catalog: CalendarView

CalendarView, as you might have guessed, displays a calendar to the user, designed to allow the user to pick a date. You supply a starting date, which the user then manipulates, triggering event listeners whenever the date is changed.

Note that this is a small calendar – it is not designed to show details within a date, such as appointments and times.

This view is available standalone and also as an optional adjunct to the DatePicker widget.

This view was added in API Level 11 and therefore will not be available on older versions of Android, though a backport is available that works on Android 2.2 onwards.

Key Usage Tips

If you do nothing, the CalendarView will start with today’s date, though you can call a setDate() method to pass in a Calendar object to use to change the initially-selected date. You can also call setOnDateChangeListener() to supply an OnDateChangeListener to learn when the user changes the date in the CalendarView.

CalendarView works well with Calendar and GregorianCalendar, in terms of setting and getting the year/month/day-of-month from the CalendarView (as supplied to the onSelectedDayChange() method of your OnDateChangeListener) and converting it into something you can use in your code.

A Sample Usage

The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).

Visual Representation

The preview of this section was stepped on by Godzilla.