Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.view.Gravity; import android.widget.Toast; public class Main { /** * * @param context * @param text */ public static void showLong(Context context, CharSequence text) { showLong(context, text, Gravity.CENTER); } /** * * @param context * @param text * @param gravity * @param xOffset * @param yOffset */ public static void showLong(Context context, CharSequence text, int gravity, int xOffset, int yOffset) { Toast t = Toast.makeText(context, text, Toast.LENGTH_LONG); t.setGravity(gravity, xOffset, yOffset); t.show(); } /** * * @param context * @param text * @param gravity */ public static void showLong(Context context, CharSequence text, int gravity) { showLong(context, text, gravity, 0, 0); } /** * * @param context * @param resId */ public static void showLong(Context context, int resId) { showLong(context, resId, Gravity.CENTER); } /** * * @param context * @param resId * @param gravity * @param xOffset * @param yOffset */ public static void showLong(Context context, int resId, int gravity, int xOffset, int yOffset) { showLong(context, context.getString(resId), gravity, xOffset, yOffset); } /** * * @param context * @param resId * @param gravity */ public static void showLong(Context context, int resId, int gravity) { showLong(context, resId, gravity, 0, 0); } }