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