The Toast util class : Toast « UI « Android






The Toast util class

  
//package com.galapk.litelisten.util;

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

/**
 * The Toast util class
 * @author pangsy
 * @createDate 2011-7-1
 * @version v0.1
 */
public final class ToastUtil {

    /**
     * Toast the long text
     * @param context
     * @param text
     */
    public static void ToastLong(Context context, String text) {
        Toast.makeText(context, text, Toast.LENGTH_LONG).show();
    }

    /**
     * Toast the long text
     * @param context
     * @param resId
     */
    public static void ToastLong(Context context, int resId) {
      Resources res = context.getResources();
      Toast.makeText(context, res.getString(resId), Toast.LENGTH_LONG).show();
    }
    
    /**
     * Toast the short text
     * @param context
     * @param resId
     */
    public static void ToastShort(Context context, int resId) {
        Resources res = context.getResources();
      Toast.makeText(context, res.getString(resId), Toast.LENGTH_SHORT).show();
    }
    
    /**
     * Toast the short text
     * @param context
     * @param text
     */
    public static void ToastShort(Context context, String text) {
        Toast.makeText(context, text, Toast.LENGTH_SHORT).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.Make Toast Text
7.Responsible for sending Toasts under all circumstances.
8.Toast.LENGTH_SHORT
9.AlertDialog vs Toast
10.Show long,short Toast
11.show Toast in a Thread
12.Popup Debug Message