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.view.Gravity;
import android.widget.TextView;
import android.widget.Toast;

public class Main {
    public static Toast alert(Context ctx, String message) {
        Toast t = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
        TextView v = (TextView) t.getView().findViewById(android.R.id.message);
        if (v != null)
            v.setGravity(Gravity.CENTER);
        t.show();

        return t;
    }

    public static Toast alert(Context ctx, int nResID) {
        Toast t = Toast.makeText(ctx, nResID, Toast.LENGTH_SHORT);
        TextView v = (TextView) t.getView().findViewById(android.R.id.message);
        if (v != null)
            v.setGravity(Gravity.CENTER);
        t.show();

        return t;
    }
}