Make Toast Text : Toast « UI « Android






Make Toast Text

  
//package djrain.lib;

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

public class ToastEx
{
  private static Toast showing;

//  public static void makeText(Context context, String text)
//  {
//    if (showing != null)
//    {
//      showing.cancel();
//      showing = null;
//    }
//    showing = Toast.makeText(context, text, Toast.LENGTH_SHORT);
//    showing.show();
//  }

  public static void makeText(Context context, String text)
  {
    if (showing == null)
    {
      showing = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    }
    else
    {
      showing.setText(text);
    }
    showing.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.Show Toast
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