Android---hellword Simple tips box

Source: Internet
Author: User

    1. Add Common Unit file com: Java

Package Com.example.myapplication;import Android.app.alertdialog;import Android.content.context;import Android.widget.toast;public class COM {//hint information public static void ShowMsg (String msg,context Context) {        Alertdialog.builder dlg = new Alertdialog.builder (context);        Dlg.settitle ("hint");        Dlg.setmessage (msg);        Dlg.setpositivebutton ("OK", null);        Dlg.show ();} Flashing hint public static void Displaytoast (String msg,context context) {Toast.maketext (context, MSG, toast.length_short). Show ();}}


2. Drag in a Button, Button Event association method name

3.mainactivity.java New method name btn_clicked and call the Com.java method

    public void btn_clicked (view view) {        com. ShowMsg ("This is the Cue box", mainactivity.this);        Com. Displaytoast ("This is a flashing hint", getbasecontext ());    }

4. Operation Effect



Android---hellword Simple tips box

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.