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