Java tutorial
//package com.java2s; import android.content.Context; import android.widget.Toast; public class Main { public static Toast mToast; public static void showToast(final Context context, final String message) { if (mToast == null) { mToast = Toast.makeText(context, message, Toast.LENGTH_SHORT); } else { mToast.setText(message); mToast.setDuration(Toast.LENGTH_SHORT); } mToast.show(); } public static void showToast(final Context context, final int messageResId) { if (mToast == null) { mToast = Toast.makeText(context, messageResId, Toast.LENGTH_SHORT); } else { mToast.setText(messageResId); mToast.setDuration(Toast.LENGTH_SHORT); } mToast.show(); } }