以下是自己總結的Toast工具類
public class ToastUtil{
public static boolean isShow = true;
/**
*短時間顯示Toast
*
**/
public static void showShort(Context context,CharSequence message){
if(isShow){
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
}
public static void showShort(Context context,int message){
if(isShow){
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
}
}
public static void showLong(Context context,CharSequence message){
if(isShow){
Toast.makeText(context,message,Toast.LENGTH_LONG).show();
}
}
public static void showLong(Context context,int message){
if(isShow){
Toast.makeText(context,message,Toast.LENGTH_LONG).show();
}
}
public static void show(Context context,CharSequence message,int duration){
Toast.makeText(context,message,duration).show();
}
public static void show(Context context,int message,int duration){
if(isShow){
Toast.makeText(context,message,duration).show();
}
}
}