Android Package Dialog

Source: Internet
Author: User

1  Packagecom.example.myandroid01;2 3 Importandroid.support.v7.app.ActionBarActivity;4 ImportAndroid.os.Bundle;5 ImportAndroid.view.Menu;6 ImportAndroid.view.MenuItem;7 ImportAndroid.view.View;8 ImportAndroid.widget.Button;9 ImportAndroid.widget.Toast;Ten /** One * Android Package Dialog A * @Describe: - * @package: com.example.myandroid01 -  * @authorshaobn the * @date 2015-9-14 pm 2:35:49 -  */ -  Public classMainactivityextendsactionbaractivity { -     PrivateButton button1; +     PrivateButton button2; -     PrivateCustomdialog Cdcustomdialog; +     Private Static FinalString TITLE = "Warning"; A     Private Static FinalString MESSAGE = "OK delete?" "; at     Private Static FinalString buttonname = "OK"; - @Override -     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); -Button1 = (Button) This. Findviewbyid (r.id.button1); inButton2 = (Button) This. Findviewbyid (r.id.button2); -Button1.setonclicklistener (NewView.onclicklistener () { to              + @Override -              Public voidOnClick (View arg0) { the                 //TODO auto-generated Method Stub *Cdcustomdialog =NewCustomdialog (mainactivity. This); $Cdcustomdialog.createdialog (Title,message, ButtonName,NewDialoginter () {Panax Notoginseng                      - @Override the                      Public voidCallbackBooleanflag) { +                         //TODO auto-generated Method Stub AToast.maketext (Getapplicationcontext (), "clicked", 1). Show (); the                     } +                 }); -             } $         }); $Button2.setonclicklistener (NewView.onclicklistener () { -              - @Override the              Public voidOnClick (View arg0) { -                 //TODO auto-generated Method StubWuyiCdcustomdialog =NewCustomdialog (mainactivity. This); theCdcustomdialog.toastdialog ("Sure"); -             } Wu         }); -     }     About}
1  Packagecom.example.myandroid01;2 3 ImportAndroid.app.AlertDialog;4 ImportAndroid.content.Context;5 ImportAndroid.content.DialogInterface;6 ImportAndroid.content.DialogInterface.OnClickListener;7 ImportAndroid.widget.Toast;8 /**9 * Custom Dialog ClassTen * @Describe: One * @package: com.example.myandroid01 A  * @authorshaobn - * @date 2015-9-14 pm 2:36:17 -  */ the classCustomdialog { -     Privatecontext context; -     PrivateAlertdialog.builder Builder; -      PublicCustomdialog (Context context) { +         //TODO auto-generated Constructor stub -          This. Context =context; +     } A      Public voidCreatedialog (String title,string message,string buttonname,FinalDialoginter Dialoginter) { atBuilder =NewAlertdialog.builder (context); - Builder.settitle (title); - builder.setmessage (message); -Builder.setpositivebutton (ButtonName,NewOnclicklistener () { -              - @Override in              Public voidOnClick (Dialoginterface arg0,intarg1) { -                 //TODO auto-generated Method Stub toDialoginter.callback (true); +             } -         }); the builder.create (). Show (); *     } $      Public voidtoastdialog (String message) {Panax Notoginseng Toast.maketext (context, Message,toast.length_long). Show (); -     } the      + } A Interfacedialoginter{ the         voidCallbackBooleanflag); +}

Android Package 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.