android dialog Box dialog

Source: Internet
Author: User

The first is the confirmation dialog box

Confirm dialog box    private void ShowLog1 () {        alertdialog.builder dialog = new Alertdialog.builder (this);        Dialog.settitle ("Tsinghua University"); Set        the title Dialog.seticon (r.mipmap.ic_launcher);//Set Picture        dialog.setmessage ("Confirm to apply for Tsinghua University?") "); Set content        Dialog.setpositivebutton ("Confirm", new Dialoginterface.onclicklistener () {//Confirm Anne            @Override            Public void OnClick (Dialoginterface dialog, int which) {                toast.maketext (mainactivity.this, "You're Awesome", toast.length_short). Show ();            }        });        Dialog.setnegativebutton ("Cancel", new Dialoginterface.onclicklistener () {//Cancel button            @Override public            Void OnClick (dialoginterface dialog, int which) {                toast.maketext (mainactivity.this, "True Pity", Toast.length_short). Show ( );            }        });        Dialog.show ();//Don't forget to show the dialog box out    }

Single-selection dialog box

Radio dialog box    private void ShowLog2 () {        alertdialog.builder dialog = new Alertdialog.builder (this);        Dialog.settitle ("Choose Gender");        Dialog.seticon (r.mipmap.ic_launcher);        Dialog.setsinglechoiceitems (Sex, 0, new Dialoginterface.onclicklistener () {            @Override public            void OnClick ( Dialoginterface dialog, int which) {                String str = Sex[which];                Toast.maketext (Mainactivity.this, "You have selected" +str, Toast.length_short). Show ();            }        );        Dialog.show ();    }

Multi-Select dialog box

List dialog box

The list dialog box    private void ShowLog4 () {        alertdialog.builder  dialog = new Alertdialog.builder (this);        Dialog.settitle ("hobby list");        Dialog.seticon (r.mipmap.ic_launcher);        Dialog.setitems (item, new Dialoginterface.onclicklistener () {            @Override public            void OnClick (dialoginterface dialog, int which) {                toast.maketext (mainactivity.this, "I Like" +item[which]+ "!", Toast.length_short). Show ();        });        Dialog.show ();    }

android dialog Box 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.