Android Development--toast Knowledge

Source: Internet
Author: User

Toast.maketext (This, "content", Toast.length_short). Show ();



Show a toast directly, the third argument is the length of time, and a toast.length_long that represents a long time

This toast can still be set to a location, however, to require an object

 Public void Toast (String m) {        = Toast.maketext (This, "M", Toast.length_short);        Mtos.setgravity (Gravity.center,0,0);    }

Create a new Toast object, call the static method Toast.maketext () method, assign the value to MTOs, and then, by calling the Setgravity () method call, the main parameter of this method is the first one, Gravity.center is set in the center display, there are other parameters such as Gravity.vercital_center and so on, the English name should be very obvious, here is not much to say, directly by calling the automatic prompt selection on the line!

PS: In general, the toast is defined in a method, in which a string parameter is defined, and then it needs to be used, just call the method and pass in the characters that need to be displayed as arguments.

Android Development--toast Knowledge

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.