Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**
     * 
     * @param context
     * @param text
     */
    public static void showShort(Context context, CharSequence text) {
        showShort(context, text, Gravity.CENTER);
    }

    /**
     * 
     * @param context
     * @param text
     * @param gravity
     * @param xOffset
     * @param yOffset
     */
    public static void showShort(Context context, CharSequence text, int gravity, int xOffset, int yOffset) {
        Toast t = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        t.setGravity(gravity, xOffset, yOffset);
        t.show();
    }

    /**
     * 
     * @param context
     * @param text
     * @param gravity
     */
    public static void showShort(Context context, CharSequence text, int gravity) {
        showShort(context, text, gravity, 0, 0);
    }

    /**
     * 
     * @param context
     * @param resId
     */
    public static void showShort(Context context, int resId) {
        showShort(context, resId, Gravity.CENTER);
    }

    /**
     * 
     * @param context
     * @param resId
     * @param gravity
     * @param xOffset
     * @param yOffset
     */
    public static void showShort(Context context, int resId, int gravity, int xOffset, int yOffset) {
        showShort(context, context.getString(resId), gravity, xOffset, yOffset);
    }

    /**
     * 
     * @param context
     * @param resId
     * @param gravity
     */
    public static void showShort(Context context, int resId, int gravity) {
        showShort(context, resId, gravity, 0, 0);
    }
}