Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import android.view.Gravity;

import android.widget.Toast;

public class Main {
    private static Toast showToast = null;

    public static void showTip(Context context, String text, boolean isInter) {
        if (null == showToast) {
            showToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        } else {
            if (isInter) {
                showToast.cancel();
                showToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
            } else {
                showToast.setText(text);
            }
        }
        showToast.setGravity(Gravity.BOTTOM, 0, 0);
        showToast.show();
    }

    public static void showTip(Context context, int resId, boolean isInter) {
        if (null == showToast) {
            showToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
        } else {
            if (isInter) {
                showToast.cancel();
                showToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
            } else {
                showToast.setText(resId);
            }
        }
        showToast.setGravity(Gravity.BOTTOM, 0, 0);
        showToast.show();
    }
}