Advanced Controls "Android 5"-Dialog action events

Source: Internet
Author: User

Event Processing Interface

Interface Name

Describe

Dialoginterface.onclicklistener

dialog box Click event handler Interface

Dialoginterface.oncancellistener

dialog box cancels the event processing interface

Dialoginterface.ondismisslistener

dialog box Hide Event processing interface

Dialoginterface.onkeylistener

dialog box keyboard Event processing interface

Dialoginterface.onmultichioceclicklistener

dialog box multi-select event processing interface

Dialoginterface.onshowlistener

dialog box displays the event processing interface

Dialog Action Events

Delete

1 protected voidonCreate (Bundle savedinstancestate) {2     Super. OnCreate (savedinstancestate);3Setcontendview (R.layout.dialog);//setting up the layout manager4Button BT =(Button) Findviewbyid (R.id.button);5Bt.setonclicklistener (NewOnclicklistener () {6          Public voidOnClick (View v) {7Dialog dialog2=NewAlertdialog.builder (Dialog0. This)8. Settitle ("delete")//Set Title9. Setmessage ("Do you want to delete the specified content?" ")//Display InformationTen. Setpositivebutton ("OK",NewDialoginterface.onclicklistener () { One                      Public voidOnClick (Dialoginterface Dialog,intwhich) { A                     }}) -. Setneutralbutton ("Cancel",NewDialoginterface.onclicklistener () { -                      Public voidOnClick (Dialoginterface Dialog,intwhich) { the                     }}) -. Create ();//Create Dialog -Dialog2.show ();//Show dialog Box -             } +         }); -}
View Code

Exit

Dialog dialog2=NewAlertdialog.builder (Dialog0. This). Settitle ("Exit")//Set Title. Setmessage ("Do you want to quit the program?" ")//Display Information. Setpositivebutton ("OK",NewDialoginterface.onclicklistener () { Public voidOnClick (Dialoginterface Dialog,intwhich) {Dialog0. This. Finish ();//Exit Program}}). Setneutralbutton ("Cancel",NewDialoginterface.onclicklistener () { Public voidOnClick (Dialoginterface Dialog,intwhich)                            {}}). Create (); //Create DialogDialog2.show ();//Show dialog Box
View Code

"Progress Processing"

1Button BT =(Button) Findviewbyid (R.ID.DBT);2Bt.setonclicklistener (NewOnclicklistener () {3      Public voidOnClick (View v) {4         FinalProgressDialog Pd=progressdialog.show (Dialog01. This,5"Search", "trying to load in ... ");6         NewThread () {//Thread Object7              Public voidRun () {//Thread Principal method8                 Try {9Thread.Sleep (3000);//Close the dialog box after 3 seconds of runningTen}Catch(interruptedexception e) { One e.printstacktrace (); A}finally{ -Pd.dismiss ();//Close the dialog box -                 } the              } -}.start ();//Thread Start - pd.show (); -      } +});
View Code

Advanced Controls "Android 5"-Dialog action events

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.