Java tutorial
//package com.java2s; import android.content.Context; import android.view.Gravity; import android.widget.Toast; public class Main { private static Context mContext; private static Toast mToast; private static void getToast(int duration) { if (mToast == null) { mToast = new Toast(mContext); mToast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); mToast.setDuration(duration); } } }