android--Simple dialog box implementation

Source: Internet
Author: User

Click on a button to pop up a simple dialog box:

Bn3.setonclicklistener (NewView.onclicklistener () { Public voidOnClick (View source) {Alertdialog.builder Builder=NewAlertdialog.builder (Editnote. This). Settitle ("Warn"). SetIcon (R.DRAWABLE.IMGBTN1). Setmessage ("Simple dialog box"); //setting options for dialog boxesBuilder.setpositivebutton ("OK",NewOnclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {Toast Toast= Toast.maketext (editnote. This,                                "Clicked the OK button.", Toast.length_short);                    Toast.show ();                }                }); //setting the Cancellation options for the dialog boxBuilder.setnegativebutton ("Cancel",NewOnclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {Toast Toast= Toast.maketext (editnote. This,                                "The Cancel button was clicked.", Toast.length_short);                    Toast.show ();                }                }); //Builder.setcancelable (false);            Builder.show (); }        });

where the setcancelable () function means: set to False, pressing the return key cannot exit. The default is true.

android--Simple dialog box implementation

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.