Android Datepickerdialog Timepickerdialog

Source: Internet
Author: User

1  PackageCom.example.myact5;2 3 ImportJava.util.Calendar;4 5 ImportAndroid.app.DatePickerDialog;6 ImportAndroid.app.DatePickerDialog.OnDateSetListener;7 ImportAndroid.app.TimePickerDialog;8 ImportAndroid.app.TimePickerDialog.OnTimeSetListener;9 ImportAndroid.os.Bundle;Ten Importandroid.support.v7.app.ActionBarActivity; One ImportAndroid.view.View; A ImportAndroid.view.View.OnClickListener; - ImportAndroid.widget.Button; - ImportAndroid.widget.DatePicker; the ImportAndroid.widget.TimePicker; - ImportAndroid.widget.Toast; - /** -  *  + * @Describe: - * @package: Com.example.myact5 +  * @authorshaobn A * @date 2015-9-11 a.m. 9:10:28 at  */ -  Public classMainactivityextendsactionbaractivity { -     Privatebutton button; -     PrivateButton button2; -     PrivateCalendar Calendar =calendar.getinstance (); - @Override in     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); to Setcontentview (r.layout.activity_main); +Button = (Button) This. Findviewbyid (r.id.button1); -Button2 = (Button) This. Findviewbyid (r.id.button2); theButton.setonclicklistener (NewOnclicklistener () { *              $ @OverridePanax Notoginseng              Public voidOnClick (View arg0) { -                 //TODO auto-generated Method Stub theTimepickerdialog TPD =NewTimepickerdialog (mainactivity. This,NewOntimesetlistener () { +                  A @Override the                  Public voidOntimeset (Timepicker arg0,intArg1,intarg2) { +                     //TODO auto-generated Method Stub -Toast.maketext (mainactivity. This, Getconstantinstance (). hourofday+ "," + getconstantinstance (). Minute, 1). Show (); $                 } $}, Getconstantinstance (). Hourofday, Getconstantinstance (). Minute,true);  - tpd.show (); -             } the         }); -Button2.setonclicklistener (NewOnclicklistener () {Wuyi              the @Override -              Public voidOnClick (View arg0) { Wu                 //TODO auto-generated Method Stub -Datepickerdialog DPD =NewDatepickerdialog (mainactivity. This,NewOndatesetlistener () { About                      $ @Override -                      Public voidOndateset (DatePicker arg0,intArg1,intArg2,intArg3) { -                         //TODO auto-generated Method Stub -Toast.maketext (mainactivity. This, arg1+ "," + (arg2+1) + "," +ARG3, 1). Show (); A                     } + }, Getconstantinstance (). Year, Getconstantinstance (). Monthofyear, Getconstantinstance (). DayOfMonth); 
     the dpd.show (); -             } $         }); the     }     the     classconstant{ the          Public intHourofday =Calendar.get (calendar.hour_of_day); the          Public intminute =Calendar.get (calendar.minute); -          Public BooleanIs24hourview =true; in          Public intYear =Calendar.get (calendar.year); the          Public intMonthofyear =Calendar.get (calendar.month); the          Public intDayOfMonth =Calendar.get (calendar.day_of_month); About     } the      PublicConstant getconstantinstance () { the         return NewConstant (); the     } +}

I wrote the trouble point, in order to practice.

Android Datepickerdialog Timepickerdialog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.