Android Siege Lion Dialog

Source: Internet
Author: User

1  Public classMainactivityextendsactionbaractivity {2String[] single_list = {"Male", "female" };3String[] Multi_list = {"Eat", "Sleep", "Hit the Peas" };4String[] Item_list = {"Manager", "Planning", "Test", "art" };5 6 @Override7     protected voidonCreate (Bundle savedinstancestate) {8         Super. OnCreate (savedinstancestate);9 Setcontentview (r.layout.fragment_main);Ten initevent (); One  A     } -  -     Private voidinitevent () { the         //TODO auto-generated Method Stub -Findviewbyid (R.ID.BUTTON5). Setonclicklistener (NewOnclicklistener () { -  - @Override +              Public voidOnClick (View v) { -                 //TODO auto-generated Method Stub +                 //showDialog1 (); A                 //showDialog2 (); at                 //ShowDialog3 (); -                 //showDialog4 (); - showDialog5 (); -             } -  -         }); in     } -  to     //Display the custom dialog box +     Private voidShowDialog5 () { -         //TODO auto-generated Method Stub theLayoutinflater Inflater = Layoutinflater.from ( This); *View view = Inflater.inflate (R.layout.dialog,NULL); $Alertdialog.builder Builder =NewAlertdialog.builder ( This);Panax NotoginsengBuilder.settitle ("Customize dialog box"); - Builder.seticon (r.drawable.ic_launcher); the Builder.setview (view); +Alertdialog dialog =builder.create (); A dialog.show (); the     } +  -     //Display List dialog box $     Private voidShowDialog4 () { $         //TODO auto-generated Method Stub -Alertdialog.builder Builder =NewAlertdialog.builder ( This); -Builder.settitle ("Department list"); the Builder.seticon (r.drawable.ic_launcher); -Builder.setitems (Item_list,NewDialoginterface.onclicklistener () {Wuyi  the @Override -              Public voidOnClick (Dialoginterface Dialog,intwhich) { Wu                 //TODO auto-generated Method Stub -Toast.maketext (mainactivity. This, "Department is yes:" + Item_list[which], 0) About . Show (); $             } -         }); -  -Alertdialog dialog =builder.create (); A dialog.show (); +     } the  -     //Show radio button dialog box $     Private voidshowDialog2 () { the         //TODO auto-generated Method Stub theAlertdialog.builder Builder =NewAlertdialog.builder ( This); theBuilder.settitle ("Choose Gender"); the Builder.seticon (r.drawable.ic_launcher); -Builder.setsinglechoiceitems (single_list, 0, in                 NewDialoginterface.onclicklistener () { the  the @Override About                      Public voidOnClick (Dialoginterface Dialog,intwhich) { the                         //TODO auto-generated Method Stub theString str =Single_list[which]; theToast.maketext (mainactivity. This, "This is everyone:" + str, 0) + . Show (); -                     } the                 });Bayi  theAlertdialog dialog =builder.create (); the dialog.show (); -     } -  the     //Display the Multi-Select button dialog box the     Private voidShowDialog3 () { the         //TODO auto-generated Method Stub theAlertdialog.builder Builder =NewAlertdialog.builder ( This); -Builder.settitle ("Hobby:"); the Builder.seticon (r.drawable.ic_launcher); theBuilder.setmultichoiceitems (Multi_list,NULL, the                 NewDialoginterface.onmultichoiceclicklistener () {94  the @Override the                      Public voidOnClick (Dialoginterface Dialog,intwhich, the                             BooleanisChecked) {98                         //TODO auto-generated Method Stub About                         if(isChecked) { -Toast.maketext (mainactivity. This,101"Hobby is:" + Multi_list[which], 0). Show ();102                         }103 104                     } the                 });106Builder.setnegativebutton ("Cancel",NewDialoginterface.onclicklistener () {107 108 @Override109              Public voidOnClick (Dialoginterface Dialog,intwhich) { the                 //TODO auto-generated Method Stub111 Dialog.dismiss (); the             }113         }); theAlertdialog dialog =builder.create (); the dialog.show (); the     }117 118     //Show confirmation dialog box119     Private voidShowDialog1 () { -Alertdialog.builder Builder =NewAlertdialog.builder ( This);121Builder.settitle ("Confirmation dialog box");122Builder.setmessage ("Confirmation Prompt dialog box contents");123 Builder.seticon (r.drawable.ic_launcher);124Builder.setpositivebutton ("Confirm",NewDialoginterface.onclicklistener () { the 126 @Override127              Public voidOnClick (Dialoginterface Dialog,intwhich) { -                 //TODO auto-generated Method Stub129Toast.maketext (mainactivity. This, "clicked OK", 0). Show (); the 131             } the         });133Builder.setnegativebutton ("Cancel",NewDialoginterface.onclicklistener () {134 135 @Override136              Public voidOnClick (Dialoginterface Dialog,intwhich) {137                 //TODO auto-generated Method Stub138Toast.maketext (mainactivity. This, "clicked Cancel", 0). Show ();139  $             }141         });142Alertdialog dialog =builder.create ();143 dialog.show ();144     }145 146}

Android Siege Lion Dialog

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.