Android examples for User Interface:Toast
Shows a short toast display and set gravity
//package com.java2s; import android.content.Context; import android.view.Gravity; import android.widget.Toast; public class Main { /**/*from ww w .j a v a 2 s. c om*/ * Shows a short toast display * * @param ctx application context * @param message message to display */ public static void showToast(Context ctx, String message) { Toast toast = Toast.makeText(ctx, message, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } }