Example usage for android.widget Toast makeText

List of usage examples for android.widget Toast makeText

Introduction

In this page you can find the example usage for android.widget Toast makeText.

Prototype

public static Toast makeText(Context context, @StringRes int resId, @Duration int duration)
        throws Resources.NotFoundException 

Source Link

Document

Make a standard toast that just contains a text view with the text from a resource.

Usage

From source file:Main.java

public static void showLong(Context context, int message) {
    if (showToast)
        Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void showToast(Context context, int resId) {
    Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*  ww w  .  jav a  2 s  .c  o m*/
}

From source file:Main.java

public static void showLToast(Context context, int resId) {
    Toast toast = Toast.makeText(context, resId, Toast.LENGTH_LONG);
    ;//  w w w.  j  a  v a  2s  . co  m
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}

From source file:Main.java

public static void showToast(String msg, boolean isShort) {

    int dur;//  w  w w.  j a v  a  2  s  .c  om
    if (isShort)
        dur = Toast.LENGTH_SHORT;
    else
        dur = Toast.LENGTH_LONG;
    if (toast != null)
        toast.cancel();
    toast = Toast.makeText(context, msg, dur);
    toast.show();
}

From source file:Main.java

/**
 * General Purpose Toast*///w  ww  .  ja  va  2s . com
public static void showToast(Context context, int resId) {
    Toast.makeText(context, resId, Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void showToast(String msg, boolean isShort) {
    int dur = 0;/*from www .j  a  v a 2  s.co  m*/
    if (isShort)
        dur = Toast.LENGTH_SHORT;
    else
        dur = Toast.LENGTH_LONG;
    if (toast != null)
        toast.cancel();
    toast = Toast.makeText(context, msg, dur);
    toast.show();
}

From source file:Main.java

public static void ToastMessage(Context cont, String msg, int time) {
    Toast.makeText(cont, msg, time).show();
}

From source file:Main.java

/**
 * Shows a toast message within the context, showing the message for a
 * certain duration/*from ww  w  . ja  v a  2s.  c om*/
 * 
 * @param context
 * @param message
 * @param duration
 */
public static void showToastMessage(Context context, int message, int duration) {
    Toast toast = Toast.makeText(context, message, duration);
    toast.show();
}

From source file:Main.java

private static final void toast(final boolean isAutoTweet, final Context context, final String text) {
    if (isAutoTweet == false) {
        if (!((Activity) context).isFinishing()) {
            if (currentThreadIsUiThread()) {
                Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
            } else {
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override/*w w w . j  a  v a 2 s .co  m*/
                    public final void run() {
                        Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }
}

From source file:Main.java

public static void makeToast(Context context, int stringResId, int length) {

    Toast.makeText(context, stringResId, length).show();
}