【Android】时间与日期Widget(DatePicker 与 TimePicker)
public class
DatePicker
extendsFrameLayout
java.lang.Object ↳ android.view.View ↳ android.view.ViewGroup ↳ android.widget.FrameLayout ↳ android.widget.DatePicker

Class Overview
This class is a widget for selecting a date. The date can be selected by a year, month, and day spinners or aCalendarView. The set of spinners and the calendar view are automatically synchronized. The client can customize whether only the spinners, or only the calendar view, or both to be displayed. Also the minimal and maximal date from which dates to be selected can be customized.
See theDate Picker tutorial.
To provide a widget for selecting a date, use theDatePickerwidget, which allows the user to select the month, day, and year, in a familiar interface.
In this tutorial, you'll create aDatePickerDialog, which presents the date picker in a floating dialog box at the press of a button. When the date is set by the user, aTextViewwill update with the new date.
public class
TimePicker
extendsFrameLayout
java.lang.Object ↳ android.view.View ↳ android.view.ViewGroup ↳ android.widget.FrameLayout ↳ android.widget.TimePicker

Class Overview
A view for selecting the time of day, in either 24 hour or AM/PM mode. The hour, each minute digit, and AM/PM (if applicable) can be conrolled by vertical spinners. The hour can be entered by keyboard input. Entering in two digit hours can be accomplished by hitting two digits within a timeout of about a second (e.g. '1' then '2' to select 12). The minutes can be entered by entering single digits. Under AM/PM mode, the user can hit 'a', 'A", 'p' or 'P' to pick. For a dialog using this view, seeTimePickerDialog.
See theTime Picker tutorial.
下面是一个转载自书上的示例: