Tuesday, 30 August 2016

How to dismiss the multiple Toast in android

Here is the code to dismiss the multiple toast messages.
Toast toast;
public void showToast(String message){
        try{
            toast.getView().isShown();     // true if visible
            toast.setText(message);
        } catch (Exception e) {         // invisible if exception
            toast = Toast.makeText(ToastDismissDemo.this, message,                                                 Toast.LENGTH_SHORT);
        }
        toast.show();
}

No comments:

Post a Comment