0301-app-dialog

Source: Internet
Author: User

Show 7 kinds of dialog below is the graph, then the corresponding code implementation

Implementation code

New Alertdialog.builder (Alertdialogsamples.this)                . SetIcon (R.drawable.alert_dialog_icon)                . Settitle ( R.string.alert_dialog_two_buttons_title)                . Setpositivebutton (R.STRING.ALERT_DIALOG_OK, new Dialoginterface.onclicklistener () {public                    void OnClick (dialoginterface dialog, int whichbutton) {/                        * User Clicked OK do some stuff *                    /}                })                . Setnegativebutton (R.string.alert_dialog_cancel, new Dialoginterface.onclicklistener () {public                    void OnClick (dialoginterface dialog, int whichbutton) {/                        * User Clicked Cancel so does some stuff *                /}})                . Create ();

*************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** ************************************

Implementation code

New Alertdialog.builder (Alertdialogsamples.this). SetIcon (R.drawable.alert_dialog_icon). Set                Title (r.string.alert_dialog_two_buttons_msg). Setmessage (R.STRING.ALERT_DIALOG_TWO_BUTTONS2_MSG) . Setpositivebutton (R.STRING.ALERT_DIALOG_OK, New Dialoginterface.onclicklistener () {public void O                    Nclick (dialoginterface dialog, int whichbutton) {/* User clicked OK so do some stuff */ }}). Setneutralbutton (r.string.alert_dialog_something, New Dialoginterface.onc                        Licklistener () {public void OnClick (dialoginterface dialog, int whichbutton) { /* User clicked Something so do some stuff */}}). Setnegativebutton (R.S Tring.alert_dialog_cancel, New Dialoginterface.onclicklistener () {public void OnClick (dialoginterface dialog, int whichbutton) {/* User clicked Cancel so do some stuff */}}) . Create ();
*************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** ************************************

Implementation code

new Alertdialog.builder (alertdialogsamples.this). Settitle (R.string.select_dialog). Setitems (R.a Rray.select_dialog_items, New Dialoginterface.onclicklistener () {public void OnClick (Dialoginterface D Ialog, int which) {/* User clicked so do some stuff */string[] items = Get                        Resources (). Getstringarray (R.array.select_dialog_items);  New Alertdialog.builder (Alertdialogsamples.this). Setmessage ("You selected:" + which + ",                    "+ Items[which]). Show (); }}). Create (); 
*************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** ************************************

Implementation code

mProgressDialog            = new ProgressDialog (alertdialogsamples.this);            Mprogressdialog.seticon (R.drawable.alert_dialog_icon);            Mprogressdialog.settitle (R.string.select_dialog);            Mprogressdialog.setprogressstyle (progressdialog.style_horizontal);            Mprogressdialog.setmax (max_progress); Mprogressdialog.setbutton (GetText (r.string.alert_dialog_hide), new Dialoginterface.onclicklistener () {Publ                IC void OnClick (dialoginterface dialog, int whichbutton) {/* User clicked Yes so do some stuff *            }            }); Mprogressdialog.setbutton2 (GetText (r.string.alert_dialog_cancel), new Dialoginterface.onclicklistener () {p                ublic void OnClick (dialoginterface dialog, int whichbutton) {/* User clicked No so do some stuff */ }            });

*************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** ********************************

Implementation code

New Alertdialog.builder (Alertdialogsamples.this). SetIcon (R.drawable.alert_dialog_icon). Set Title (R.string.alert_dialog_single_choice). Setsinglechoiceitems (R.ARRAY.SELECT_DIALOG_ITEMS2, 0, new Dialo                        Ginterface.onclicklistener () {public void OnClick (dialoginterface dialog, int whichbutton) { /* User clicked on a radio button do some stuff */}}). SE Tpositivebutton (R.STRING.ALERT_DIALOG_OK, New Dialoginterface.onclicklistener () {public void OnClick (D                    Ialoginterface dialog, int whichbutton) {/* User clicked Yes so do some stuff */ }}). Setnegativebutton (R.string.alert_dialog_cancel, New Dialoginterface.onclicklistener ( {public void OnClick (dialoginterface dialog, int whichbutton) {/* User click Ed No so do some stuff */}}). Create (); 


*************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** ********************************


Implementation code

New Alertdialog.builder (Alertdialogsamples.this). SetIcon (R.drawable.ic_popup_reminder). Set                        Title (R.string.alert_dialog_multi_choice). Setmultichoiceitems (R.ARRAY.SELECT_DIALOG_ITEMS3, New Boolean[]{false, True, False, True, False, False, false}, new dialoginterface.onmultic                                    Hoiceclicklistener () {public void OnClick (dialoginterface dialog, int whichbutton, Boolean isChecked) {/* User clicked on a check box do some stuff * /}}). Setpositivebutton (R.STRING.ALERT_DIALOG_OK, New D                        Ialoginterface.onclicklistener () {public void OnClick (dialoginterface dialog, int whichbutton) { /* User clicked Yes do some stuff */}}). Setnegati Vebutton (R.string.alert_Dialog_cancel, New Dialoginterface.onclicklistener () {public void OnClick (dialoginterface dialog, int               Whichbutton) {/* User clicked No so do some stuff */}}) . Create ();

*************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** ********************************

Implementation code

string[] projection = new string[] {contacts.people._id, Contacts.People.NA                ME, Contacts.People.SEND_TO_VOICEMAIL};                cursor cursor = managedquery (Contacts.People.CONTENT_URI, projection, NULL, NULL, NULL);                    return new Alertdialog.builder (alertdialogsamples.this). SetIcon (R.drawable.ic_popup_reminder)                            . Settitle (R.string.alert_dialog_multi_choice_cursor). Setmultichoiceitems (Cursor,                            Contacts.People.SEND_TO_VOICEMAIL, Contacts.People.NAME, New Dialoginterface.onmultichoiceclicklistener () {public void OnClick (DIALOGINTERFAC                                    e dialog, int Whichbutton, Boolean isChecked) {                               Toast.maketext (Alertdialogsamples.this,             "Readonly Demo Only-data won't be updated", Toast.length_shor                                T). Show (); }}). Create ();

*************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** ****************************

Implementation code

Layoutinflater factory = Layoutinflater.from (this);            Final View Textentryview = factory.inflate (r.layout.alert_dialog_text_entry, NULL);                return new Alertdialog.builder (alertdialogsamples.this). SetIcon (R.drawable.alert_dialog_icon) . Settitle (R.string.alert_dialog_text_entry). Setview (Textentryview). Setpositivebutton (R. STRING.ALERT_DIALOG_OK, New Dialoginterface.onclicklistener () {public void OnClick (Dialoginterface dia                Log, int whichbutton) {/* User clicked OK so do some stuff */}                    }). Setnegativebutton (R.string.alert_dialog_cancel, New Dialoginterface.onclicklistener () {  public void OnClick (dialoginterface dialog, int whichbutton) {/* User clicked Cancel so do Some stuff */}}). Create ();

 
 
 

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.