How to cancel Toast__java/android immediately

Source: Internet
Author: User
Toast is the most commonly used but now many of the procedures in the market do not notice a point, is the toast immediate shutdown problem
Toast played a role in prompting the cancellation should be canceled as soon as possible
User cannot manually cancel toast is a bit annoying.
Actually, it's very, very simple to close.
Add the following code to the tool class:

Package Com.xmic.moman;

Import Android.content.Context;
Import Android.widget.Toast;

public class Myutil {
     private static Toast mtoast;
     public static void Showtoast (context, int resid, int duration) {
    	 Showtoast (context, context.getstring (RESID) , duration);
     }
     public static void Showtoast (context context, String msg, int duration) {
             if (Mtoast = null) {
                     mtoast = Toast.mak EText (Context, msg, duration);
             else {
                     mtoast.settext (msg);
             }
             Mtoast.show ();
     }


Call Myutils.showtoast (Context, MSG, duration) when you want to use it;
Perfect Toast Fast Switch

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.