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

/**
 * shows a short message on top of your app... it goes away automatically after a long delay
 *//*from www .ja v  a2 s.c om*/
public static void showToastLong(Activity a, String msg) {
    Toast.makeText(a, msg, Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void showToast_Long(Context context, String text) {
    Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*from  www .ja va2 s . c  om*/
}

From source file:Main.java

public static void getShortToast(Context context, String hint) {
    if (toast == null) {
        toast = Toast.makeText(context, hint, Toast.LENGTH_SHORT);
    } else {//from   w  w w.j  a  va 2s  .  com
        toast.setText(hint);
        toast.setDuration(Toast.LENGTH_SHORT);
    }
    toast.show();
}

From source file:Main.java

public static void showToast_Short(Context context, String text) {
    Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();// w ww .j a v  a  2s . com
}

From source file:Main.java

public static void showError(String msg, Context context) {
    CharSequence text = msg;/*from w  w  w .jav  a2  s .  com*/
    int duration = Toast.LENGTH_SHORT;

    Toast toast = Toast.makeText(context, text, duration);
    toast.show();
    return;
}

From source file:Main.java

public static void showToast(Activity activity, String msg) {
    String s = String.format("animator: %s", msg);
    Toast.makeText(activity, s, Toast.LENGTH_LONG).show();
}

From source file:Main.java

/**
 * shows a short message on top of your app... it goes away automatically after a short delay
 */// w  w w.j a v a 2  s. c  om
public static void showToastShort(Activity a, String msg) {
    Toast.makeText(a, msg, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

/** shows a short message on top of your app... it goes away automatically after a short delay */
public static void showToastShort(Context a, String msg) {
    Toast.makeText(a, msg, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showTips(Context ctx, String msg) {
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(ctx, msg, duration);
    toast.show();//from w w  w  . jav  a  2s .  co m
}

From source file:Main.java

private static void show(Context context, int resId, int duration) {
    if (toast == null) {
        toast = Toast.makeText(context, resId, duration);
    } else {//from  w  ww . j a  v  a  2  s  . c om
        toast.setText(resId);
    }
    toast.show();
}