Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.widget.Toast; public class Main { public static void ShowToast(Activity activity, String str, boolean isLong) { if (isLong) { Toast.makeText(activity, str, Toast.LENGTH_LONG).show(); } else { Toast.makeText(activity, str, Toast.LENGTH_SHORT).show(); } } public static void ShowToast(Context cxt, String str, boolean isLong) { if (isLong) { Toast.makeText(cxt, str, Toast.LENGTH_LONG).show(); } else { Toast.makeText(cxt, str, Toast.LENGTH_SHORT).show(); } } }