About Android Development by Toast Display message prompt box

Source: Internet
Author: User

Toast is used to display a prompt Information bar on the screen that does not have any control buttons and does not get the focus and disappears automatically after a certain amount of time.

Function: Used to display some quick tips

There are two ways to display a prompt message box

One:

Call the Make Text () method of the Toast class to create a Toast object named Toast (custom)

Key code

1 Toast toast = Toast.maketext (this" content to display ", Toast.length_long). Show () ;

Two:

Create a message prompt by using the Toast class's construction method

Key code

1First modify the layout file to display the information, set a android:id="@+id/ll"ID yourself set the name to be Toast.setview (LL) in the code below;2 3 4Toast toast =NewToast ( This);5Toast.setduration (Toast.length_short);//Set Duration6Toast.setgravity (Gravity.center,0,0);//Set Alignment7LinearLayout ll=NewLinearLayout ( This);//Create a linear layout manager8TextView tv=NewTextView ( This);//Create a TextView9Tv.settext ("I am a message prompt created from a constructor function");//Set text contentTenLl.addview (TV);//adding TextView to the linear layout manager OneToast.setview (LL);//set the view to display in the Message prompt box AToast.show ();//Show message Prompt box

About Android Development by Toast Display message prompt 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.