Show Toast : Toast « UI « Android






Show Toast

  
/*******************************************************************************
 * Copyright (c) 2011 Benjamin Gmeiner.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Benjamin Gmeiner - Project Owner
 ******************************************************************************/
//package com.mediaportal.ampdroid.utils;

import android.content.Context;
import android.os.Vibrator;
import android.widget.Toast;


 class Util {
   public static Toast toast;
   private static String lastToastText;

   public static void showToast(Context _context, String _text) {
      if (toast != null) {
         toast.cancel();
      }
      if (_text != null && _text.equals(lastToastText)) {
         toast.show();
      } else {
         lastToastText = _text;
         toast = Toast.makeText(_context, _text, Toast.LENGTH_SHORT);
         toast.show();
      }
   }
   

}

   
    
  








Related examples in the same category

1.Raise a Toast
2.Toast Message Demo
3.Using Toast.LENGTH_SHORT
4.Toast and Notification, vibrate and sound
5.Make Toast Text
6.Responsible for sending Toasts under all circumstances.
7.Toast.LENGTH_SHORT
8.AlertDialog vs Toast
9.Show long,short Toast
10.The Toast util class
11.show Toast in a Thread
12.Popup Debug Message