Software Testing--android Application development toast

Source: Internet
Author: User

One, the Toast in Android

  A simple message prompt box.

When the view is displayed to the user, it is displayed as floating in the application.  Unlike dialog, it never gets the focus and cannot be clicked.   The user will probably type something else in the middle.  The idea of a toast class is to be as unobtrusive as possible, while also displaying information to the user in the hope that they will see it.  And toast displays a limited amount of time, and toast automatically disappears based on the display time set by the user.     The simplest way to use this class is to call a static method to construct everything you need and return a new Toast object. (Excerpt from Baidu Encyclopedia) ii.Toast General UseUse need to introduce package: import Android.widget.Toast; Common syntax--under activity:

Toast.maketext (This.getapplicationcontext (), "text needed to be displayed", Toast.length_short). Show ();

Third, the Android can use toast for Android application development process Testing

For example, to generate an object of Class B in Class A, there is a method in class B to display information using toast.

If B is an inline class of a or a method defined within a can be run with the following code:

Toast.maketext (a.this, "text needed to be displayed", Toast.length_short). Show ();

Otherwise, in B, first define the member variable context Mcontext, and then in the construction method of B to the A object as the context Mcontext to B, and then implement the method in B myshow ():

Context Mcontext;

...

B (Context context) {

Mcontext = context;

}

...

void Myshow () {

Toast.maketext (Mcontext, "text needed to be displayed", Toast.length_short). Show ();

}

  

Software Testing--android Application development toast

Related Article

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.