Java tutorial
//package com.java2s; import android.content.Context; import android.view.Gravity; import android.widget.Toast; public class Main { public static void showToast(Context ctx, String message) { Toast tost = Toast.makeText(ctx, message, Toast.LENGTH_SHORT); tost.setGravity(Gravity.CENTER, 0, 0); tost.show(); } public static void showToast(Context ctx, int resId) { String message = ctx.getString(resId); showToast(ctx, message); } }