Package COM. zhycheng; import android. app. activity; import android. app. datepickerdialog; import android. app. dialog; import android. app. timepickerdialog; import android. OS. bundle; import android. view. view; import android. view. view. onclicklistener; import android. widget. button; import android. widget. datepicker; import android. widget. timepicker; public class datepickeractivity extends activity implements onclicklistener {button button1, button2; datepickerdialog DPD; timepickerditpd TPD;/** called when the activity is first created. * // @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); button1 = (button) findviewbyid (R. id. button1); button1.setonclicklistener (this); button2 = (button) findviewbyid (R. id. button2); button2.setonclicklistener (this); DPD = new datepickerdialog (this, new datepickerdialog. ondatesetlistener () {@ overridepublic void ondateset (datepicker view, int year, int monthofyear, int dayofmonth) {system. out. println (Year + ";" + monthofyear // Note: The numbers here are from 0 to 11 + "" + dayofmonth ); TPD = new timepickerdialog (this, new timepickerdialog. ontimesetlistener () {@ overridepublic void ontimeset (timepicker view, int hourofday, int minute) {system. out. println (hourofday + ";" + minute) ;}, 12, 3, true); // true indicates the 24-hour system, false indicates 12-hour format} @ overridepublic void onclick (view v) {If (v. GETID () = R. id. button1) DPD. show (); If (v. GETID () = R. id. button2) {TPD. show ();}}}