Xml
<ButtonAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Click the trigger pop-up Date" dialog boxAndroid:onclick= "Rq_onclick"/> <ButtonAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Click the trigger pop-up Time" dialog boxAndroid:onclick= "Sj_onclick"/>
Java
Public voidRq_onclick (View v) {//Get Current date//a static method for single-case mode and design patternCalendar C =calendar.getinstance (); Datepickerdialog DPD=NewDatepickerdialog ( This,NewDatepickerdialog.ondatesetlistener () {@Override Public voidOndateset (DatePicker view,intYearintMonthofyear,intdayofmonth) {Toast.maketext (UIActivity2). This, year+ "-" + (monthofyear+1) + "-" +DayOfMonth, Toast.length_short). Show (); }},c.get (Calendar.year), C.get (Calendar.month), C.get (Calendar.day_of_month)); //Click the other section does not disappearDpd.setcancelable (false); Dpd.show (); } Public voidSj_onclick (View v) {//Get Current date//a static method for single-case mode and design patternCalendar C =calendar.getinstance (); Timepickerdialog TP=NewTimepickerdialog ( This,NewTimepickerdialog.ontimesetlistener () {@Override Public voidOntimeset (Timepicker view,intHourofday,intminute) {Toast.maketext (UIActivity2). This, hourofday+ ":" +minute, Toast.length_short). Show (); }},c.get (Calendar.hour), C.get (Calendar.minute),true); Tp.setcancelable (false); Tp.show (); }
android--dialog box 2 (Date and Time dialog box)