Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.widget.Toast;

public class Main {
    public static Toast toast = null;

    private static void show(Context context, int resId, int duration) {
        if (toast == null) {
            toast = Toast.makeText(context, resId, duration);
        } else {
            toast.setText(resId);
        }
        toast.show();
    }

    private static void show(Context context, String message, int duration) {
        if (toast == null) {
            toast = Toast.makeText(context, message, duration);
        } else {
            toast.setText(message);
        }
        toast.show();
    }
}