Toast is often used in actual use, and it is extremely invincible and convenient to use.CodeYou can do it.
Toast. maketext (This, "Content to be displayed", Toast. length_short). Show ();
If you only use this code, you will find that when you click it multiple times in a row, toast will be displayed for a long time, which is not a bug in the strict sense ~
The following method can be used to solve the problem: Only one fixed toast object is used. The maketext method will actually go to a new toast object each time and set it by using settext () and setduration, in this way, toast will be updated immediately:
// Define the variable in advance and only use this variable
Toast mytoast =NewToast (mcontext );
Layoutinflater inflate = (layoutinflater) mcontext. getsystemservice (context. layout_inflater_service );
View v = inflate. Inflate (COM. Android. Internal. R. layout. transient_notification, null );
// The setview here cannot be small. Of course, the set view can also be constructed from the layout XML written by itself.
Mytoast. setview (v );
// Set the displayed text
Mytoast. settext ("Display content");
// Duration
Mytoast. setduration (toast. length_short );
// Show
Mytoast. Show ();