Java tutorial
//package com.java2s; import android.content.Context; import android.widget.Toast; public class Main { /** * Displays a message toast * * @param context * The context the toast is displayed * @param text * The text contained in the toast */ public static void createToast(Context context, String text) { Toast.makeText(context, text, Toast.LENGTH_LONG).show(); } /** * @param context The context the toast is displayed. Can be application context. * @param text The text contained in the toast * @param shortTime Whether to display toast with shorter duration. */ public static void createToast(Context context, String text, boolean shortTime) { int duration = (shortTime) ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG; Toast.makeText(context, text, duration).show(); } }