A utility method for making a toast. - Android User Interface

Android examples for User Interface:Toast

Description

A utility method for making a toast.

Demo Code


//package com.java2s;

import android.content.Context;

import android.view.Gravity;
import android.widget.Toast;

public class Main {
    /**//from   www . j a va2 s .co m
     * A utility method for making a toast. All toast should use this method
     * that way if we need to modify them all, we can do it in one place.
     * 
     * @param context
     *            Application context
     * @param message
     *            Message to display
     */
    public static void toast(Context context, CharSequence message) {
        Toast heresToASuccessfulConnection = Toast.makeText(context,
                message, Toast.LENGTH_SHORT);
        heresToASuccessfulConnection.setGravity(Gravity.TOP, 0, 20);
        heresToASuccessfulConnection.show();
    }
}

Related Tutorials