【威哥說】今天就是感恩節(jié)了喲购岗,你近期有聯(lián)系你的家人,你的朋友嗎门粪,以及你一切想說感謝的人了嗎藕畔?定一個(gè)鬧鐘,在你今天上班可以休息的時(shí)間庄拇,記得給他們發(fā)一個(gè)QQ留言注服,或者打一通電話。說一句感謝措近。
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?磨礪營(yíng)的感恩節(jié)活動(dòng)【點(diǎn)擊我進(jìn)入】
public class TinyjoyToastUtil extends Toast {
private static boolean isShowFlag = true;
private static Toast toast;
public TinyjoyToastUtil(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
/**
* 字符串類型溶弟,短吐絲
*
* @param context
* ? ? 上下文
* @param message
* ? ? CharSequence類型的信息
*/
public static void showShort(Context context, CharSequence message) {
if (isShowFlag)
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
/**
* 以"資源ID"為消息的"短顯示吐司"
*
* @param context
* ? ? ? ? ?上下文
* @param message
* ? ? ? ? 消息的資源ID
*/
public static void showShort(Context context, int message) {
if (isShowFlag)
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
/**
* 以"字符串類型"為消息的"長(zhǎng)顯示吐司"
*
* @param context
* ? ? ? ? 上下文
* @param message
* ? ? ? ? "字符串類型的消息"
*/
public static void showLong(Context context, CharSequence message) {
if (isShowFlag)
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}
/**
* 以"字符串資源ID"為消息的"長(zhǎng)顯示吐司"
*
* @param context
* ? ? ? ? 上下文
* @param message
* ? ? ? ? 消息的資源ID
*/
public static void showLong(Context context, int message) {
if (isShowFlag)
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}
/**
* 自定義顯示位置的吐司, 短吐司, 消息為"字符串資源的ID"
*
* @param context
* ? ? ? ? 上下文
* @param charSequence
* ? ? ? ? 字符串類型的消息
* @param gravity
* ? ? ? ? 參數(shù)類型為Int型,表示在屏幕上所處的位置(如Gravity.centre表示處在屏幕中間)
* @param xOffset
* ? ? ? ? Toast這個(gè)View以Gravity.centre位置為參照物相對(duì)X軸的偏移量
* @param yOffset
* ? ? ? ? Toast這個(gè)View以Gravity.centre位置為參照物相對(duì)Y軸的偏移量
*/
public static void showCustomLocationShort(Context context, int messageId,
int gravity, int xOffset, int yOffset) {
if (isShowFlag) {
Toast toast = Toast
.makeText(context, messageId, Toast.LENGTH_SHORT);
toast.setGravity(gravity, xOffset, yOffset);
toast.show();
}
}
/**
* 自定義顯示位置的吐司, 長(zhǎng)吐司, 消息為字符串資源ID
*
* @param context
* 上下文
* ? ? ? ? @param charSequence
* 整形int的消息資源的ID值
* ? ? ? ? @param gravity
* 參數(shù)類型為Int型,表示在屏幕上所處的位置(如Gravity.centre表示處在屏幕中間)
* ? ? ? ? @param xOffset
* Toast這個(gè)View以Gravity.centre位置為參照物相對(duì)X軸的偏移量
* ? ? ? ? @param yOffset
* Toast這個(gè)View以Gravity.centre位置為參照物相對(duì)Y軸的偏移量
*/
public static void showCustomLocationLong(Context context, int messageId,
int gravity, int xOffset, int yOffset) {
if (isShowFlag) {
Toast toast = Toast.makeText(context, messageId, Toast.LENGTH_LONG);
toast.setGravity(gravity, xOffset, yOffset);
toast.show();
}
}
/**
* 自定義顯示位置的吐司, 短吐司, 消息為字符串類型
*
* @param context
* ? ? ? ? 上下文
* @param charSequence
* ? ? ? ? 字符串類型的消息
* @param gravity
* ? ? ? ? 參數(shù)類型為Int型,表示在屏幕上所處的位置(如Gravity.centre表示處在屏幕中間)
* @param xOffset
* ? ? ? ? Toast這個(gè)View以Gravity.centre位置為參照物相對(duì)X軸的偏移量
* @param yOffset
* ? ? ? ? Toast這個(gè)View以Gravity.centre位置為參照物相對(duì)Y軸的偏移量
*/
public static void showCustomLocationShort(Context context,
CharSequence message, int gravity, int xOffset, int yOffset) {
if (isShowFlag) {
Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
toast.setGravity(gravity, xOffset, yOffset);
toast.show();
}
}
/**
* 自定義顯示位置的吐司, 長(zhǎng)吐司, 消息為字符串類型
*
* @param context
* ? ? ? ? 上下文
* @param charSequence
* ? ? ? ? 字符串類型的消息
* @param gravity
* ? ? ? ? 參數(shù)類型為Int型,表示在屏幕上所處的位置(如Gravity.centre表示處在屏幕中間)
* @param xOffset
* ? ? ? ? Toast這個(gè)View以Gravity.centre位置為參照物相對(duì)X軸的偏移量
* @param yOffset
* ? ? ? ? Toast這個(gè)View以Gravity.centre位置為參照物相對(duì)Y軸的偏移量
*/
public static void showCustomLocationLong(Context context,
CharSequence charSequence, int gravity, int xOffset, int yOffset) {
if (isShowFlag) {
toast = Toast.makeText(context, charSequence, Toast.LENGTH_LONG);
toast.setGravity(gravity, xOffset, yOffset);
toast.show();
}
}
/**
* 這是一個(gè)帶圖片的吐司,其吐司的顯示位置定義在了屏幕正中間-->短吐司
* @param context
* ? ? ? ? 上下文
* @param message
* ? ? ? ? 字符串類型的消息
* @param resId
* ? ? ? ? 圖片資源ID
*/
public static void showCustomToastWithImageShort(Context context,
CharSequence message, int resId) {
if (isShowFlag) {
toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
LinearLayout ToastContentView = (LinearLayout) toast.getView();
ImageView img = new ImageView(context);
img.setImageResource(resId);
ToastContentView.addView(img);
toast.show();
}
}
/**
* 這是一個(gè)帶圖片的吐司,其吐司的顯示位置定義在了屏幕正中間-->長(zhǎng)吐司
*
* @param context
* ? ? ? ? 上下文
* @param message
* ? ? ? ? 字符串類型的消息
* @param resId
* ? ? ? ? 圖片資源ID
*/
public static void showCustomToastWithImageLong(Context context,
CharSequence message, int resId) {
if (isShowFlag) {
toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
LinearLayout ToastContentView = (LinearLayout) toast.getView();
ImageView img = new ImageView(context);
img.setImageResource(resId);
ToastContentView.addView(img);
toast.show();
}
}
/**
* 這是一個(gè)帶圖片的吐司,其吐司的顯示位置定義在了屏幕正中間-->短吐司
*
* @param context
* ? ? ? ? 上下文
* @param messageId
* ? ? ? ? 字符串資源的ID值
* @param resId
* ? ? ? ? 圖片資源ID
*/
public static void showCustomToastWithImageShort(Context context,
int messageId, int resId) {
if (isShowFlag) {
toast = Toast.makeText(context, messageId, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
LinearLayout ToastContentView = (LinearLayout) toast.getView();
ImageView img = new ImageView(context);
img.setImageResource(resId);
ToastContentView.addView(img);
toast.show();
}
}
/**
* 這是一個(gè)帶圖片的吐司,其吐司的顯示位置定義在了屏幕正中間-->長(zhǎng)吐司
*
* @param context
* ? ? ? ? 上下文
* @param messageId
* ? ? ? ? 字符串資源的ID值
* @param resId
* ? ? ? ? 圖片資源ID
*/
public static void showCustomToastWithImageLong(Context context,
int messageId, int resId) {
if (isShowFlag) {
toast = Toast.makeText(context, messageId, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
LinearLayout ToastContentView = (LinearLayout) toast.getView();
ImageView img = new ImageView(context);
img.setImageResource(resId);
ToastContentView.addView(img);
toast.show();
}
}
/**
*
* 這是一個(gè)完全自定義的短吐司Toast:所展示出來的視圖是自己在res文件夾中自定義的xml布局文件
*
* @param context
* ? ? ? ? 所在Activity的上下文
* @param layoutResource
* ? ? ? ? 所要加載的XML布局資源文件的ID值
* @param message
* ? ? ? ? 所要通知的文本信息(CharSequence形式)
* @param bitmap
* ? ? ? ? 所要通知的圖片的信息(Bitmap形式)
*
*
*/
public static void showCompletedCustomToastShort(Context context,
int layoutResource, CharSequence message, Bitmap bitmap) {
if (isShowFlag) {
toast = new Toast(context);
LayoutInflater inflate = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflate.inflate(layoutResource, null);
TextView mTextView = (TextView) view
.findViewById(R.id.toast_text_content);
ImageView mImageView = (ImageView) view
.findViewById(R.id.toast_image_content);
mTextView.setText(message);
mImageView.setImageBitmap(bitmap);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.setView(view);
toast.setDuration(TinyjoyToastUtil.LENGTH_SHORT);
toast.show();
}
}
/**
*
* 這是一個(gè)完全自定義的長(zhǎng)吐司Toast:所展示出來的視圖是自己在res文件夾中自定義的xml布局文件
*
* @param context
* ? ? ? ? 所在Activity的上下文
* @param layoutResource
* ? ? ? ? 所要加載的XML布局資源文件的ID值
* @param message
* ? ? ? ? 所要通知的文本信息(CharSequence形式)
* @param bitmap
* ? ? ? ? 所要通知的圖片的信息(Bitmap形式)
*
*/
public static void showCompletedCustomToastLong(Context context,
int layoutResource, CharSequence message, Bitmap bitmap) {
if (isShowFlag) {
toast = new Toast(context);
LayoutInflater inflate = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflate.inflate(layoutResource, null);
TextView mTextView = (TextView) view
.findViewById(R.id.toast_text_content);
ImageView mImageView = (ImageView) view
.findViewById(R.id.toast_image_content);
mTextView.setText(message);
mImageView.setImageBitmap(bitmap);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.setView(view);
toast.setDuration(TinyjoyToastUtil.LENGTH_SHORT);
toast.show();
}
}
/**
* 完全自定義的短吐司:所展示出來的視圖是自己在res文件夾中自定義的xml布局文件
*
* @param context
* ? ? ? ? 所在Activity的上下文
* @param layoutResource
* ? ? ? ? 所要加載的XML布局資源文件的ID值
* @param message
* ? ? ? ? ? ? 所要通知的文本信息(CharSequence形式)
* @param imaegId
* ? ? ? ? ? ? ? ?所要通知的圖片的信息(圖片資源ID值)
*/
public static void showCompletedCustomToastShortWithResId(Context context,
int layoutResource, CharSequence message, int imaegId) {
if (isShowFlag) {
toast = new Toast(context);
LayoutInflater inflate = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflate.inflate(layoutResource, null);
TextView mTextView = (TextView) view
.findViewById(R.id.toast_text_content);
ImageView mImageView = (ImageView) view
.findViewById(R.id.toast_image_content);
mTextView.setText(message);
mImageView.setImageResource(imaegId);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.setView(view);
toast.setDuration(TinyjoyToastUtil.LENGTH_LONG);
toast.show();
}
}
/**
* 完全自定義的長(zhǎng)吐司:所展示出來的視圖是自己在res文件夾中自定義的xml布局文件
*
* @param context
* ? ? ? ? ? ? ? ?所在Activity的上下文
* @param layoutResource
* ? ? ? ? ? ? ? ?所要加載的XML布局資源文件的ID值
* @param message
* ? ? ? ? ? ? ? ? 所要通知的文本信息(CharSequence形式)
* @param imaegId
* ? ? ? ? ? ? ? ? 所要通知的圖片的信息(圖片資源ID值)
*/
public static void showCompletedCustomToastLongWithResId(Context context,
int layoutResource, CharSequence message, int imaegId) {
if (isShowFlag) {
toast = new Toast(context);
LayoutInflater inflate = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflate.inflate(layoutResource, null);
TextView mTextView = (TextView) view
.findViewById(R.id.toast_text_content);
ImageView mImageView = (ImageView) view
.findViewById(R.id.toast_image_content);
mTextView.setText(message);
mImageView.setImageResource(imaegId);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.setView(view);
toast.setDuration(TinyjoyToastUtil.LENGTH_LONG);
toast.show();
}
}
}