Display prompt box using Toast for Android

Source: Internet
Author: User

Toast is a very convenient prompt message box. It will display a simple prompt message on the program interface, which is used to generate a simple prompt message to the user, it has two features.

1. The Toast prompts that the information will not get the focus,

2. The Toast prompts that the information will automatically disappear after a period of time.

It is also very easy to use Toast to generate the prompt message, as long as the following steps:

1. Call the Toast constructor or the makeText method to create a Toast object.

2. Call the Toast method to set the alignment, margin, and display content of the message.

3. Call the show () method of Toast to display it.

 

Public void sendMessage (View view) {// Do something in response to button Toast toast = Toast. makeText (MainActivity. this, "simple prompt information", Toast. LENGTH_SHORT); toast. show ();}

 

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.