Java tutorial
//package com.java2s; //License from project: Open Source License import android.annotation.SuppressLint; import android.content.Context; import android.view.Gravity; import android.widget.Toast; public class Main { @SuppressLint("ShowToast") public static Toast createToast(Context context, String message) { Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0); return toast; } }