Customize dialog box, Time Date dialog box

Source: Internet
Author: User

Customize dialog box

Custom dialog box public    void Bt_4 (View v)    {        //1-layout file loader        //layoutinflater layoutinflater= Getlayoutinflater ();       View view=layoutinflater.inflate (R.layout.zidingyiduihuakuang, null);        2-view static method        //view View=view.inflate (this, r.layout.zidingyiduihuakuang, null);        3-java code        ImageView view=new ImageView (this);        View.setimageresource (r.drawable.nnn);        New Alertdialog.builder (This)                //.setview (R.layout.zidingyiduihuakuang) version 5 or higher.                . Setview (view)                . Show ();    }
View Code

Get the current time date

 Gets the current date//Singleton mode Calendar c=calendar.getinstance ();    C.get (calendar.year); Date dialog box public void Bt_6 (View v) {datepickerdialog dp=new datepickerdialog (this, new datepickerdialog.ondate Setlistener () {@Override public void Ondateset (DatePicker view, int. year, int monthofyear, int dayo Fmonth) {Toast.maketext (Text5activity.this, year+ "-" +monthofyear+1+ "-" +dayofmonth, Toast.length_short). Sho            W ();        }}, C.get (Calendar.year), C.get (Calendar.month), C.get (Calendar.day_of_month));    Dp.show (); }//Time dialog public void bt_7 (View v) {timepickerdialog tp=new timepickerdialog (this, new TIMEPICKERDIALOG.O                Ntimesetlistener () {@Override public void Ontimeset (timepicker view, int hourofday, int minute) {            Toast.maketext (Text5activity.this, hourofday+ ":" +minute, Toast.length_short). Show ();  }}, C.get (Calendar.hour), C.get (Calendar.minute), true);      Tp.setcanceledontouchoutside (FALSE);    Tp.show (); }
View Code

Time dialog box

Time dialog box public    void bt_7 (View v)    {        Timepickerdialog tp=new timepickerdialog (This, new Timepickerdialog.ontimesetlistener () {            @Override public            void Ontimeset (timepicker view, int hourofday, int minute) {                toast.maketext (text5activity.this, hourofday+ ":" +minute, Toast.length_short). Show ();            }        , C.get (Calendar.hour), C.get (Calendar.minute), true);        Tp.setcanceledontouchoutside (false);        Tp.show ();;    }
View Code

Date dialog box

Date dialog box public    void Bt_6 (View v)    {        Datepickerdialog dp=new datepickerdialog (This, new Datepickerdialog.ondatesetlistener () {            @Override public            void Ondateset (DatePicker view, int. year, int monthofyear, int dayofmonth) {                toast.maketext (text5activity.this, year+ "-" +monthofyear+1+ "-" +dayofmonth, Toast.length_short). Show ();            }        , C.get (calendar.year), C.get (Calendar.month), C.get (calendar.day_of_month ));        Dp.show ();;    }
View Code

Customize dialog box, Time Date dialog box

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.