Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.widget.Toast; public class Main { /** * show Short Image Toast * See{@link #showImageToast(Context, int, String, int)} * * @param context :context * @param ImageResId : imageres id * @param text : the msg you will show */ public static void showShortImageToast(Context context, int ImageResId, String text) { showImageToast(context, ImageResId, text, Toast.LENGTH_SHORT); } /** * show toast with image * * @param context :context * @param ImageResId :imgres id * @param text :the msg you will show * @param times :time */ @SuppressWarnings("static-access") public static void showImageToast(Context context, int ImageResId, String text, int times) { if (context == null || text == null || "".equals(text)) return; // LayoutInflater inflater = (LayoutInflater) context // .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // // View view = inflater.inflate(R.layout.dfjk_lay_custom_toast, null); // ImageView image = (ImageView) view.findViewById(R.id.dfjk_im_toast_image); // TextView textView = (TextView) view.findViewById(R.id.dfjk_tv_toast_message); // // if (0 != ImageResId) { // image.setVisibility(view.VISIBLE); // image.setImageResource(ImageResId); // } else // image.setVisibility(view.GONE); // textView.setText(text); // mHandler.removeCallbacks(run); // // if (mToast != null) { // mToast.cancel(); // mToast = new Toast(context); // mToast.setDuration(times); // mToast.setGravity(Gravity.BOTTOM, 0, 150); // mToast.setView(view); // mHandler.postDelayed(run, 500); // } else { // mToast = new Toast(context); // mToast.setDuration(times); // mToast.setGravity(Gravity.BOTTOM, 0, 150); // mToast.setView(view); // mToast.show(); // } } }