Java tutorial
//package com.java2s; import android.content.Context; import android.view.Gravity; import android.widget.Toast; public class Main { private static Toast toast; public static void showCenterTextToast(Context context, String msg) { if (toast == null) { toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT); } else { toast.setText(msg); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } }