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 Toast showToast(Context context, String textMessage, int timeDuration) {
    if (context == null) {
        return null;
    }/*from w ww.  j  a va 2  s.  co m*/
    Toast t = Toast.makeText(context, textMessage == null ? "Oops! " : textMessage.trim(), timeDuration);
    t.show();
    return t;
}

From source file:Main.java

/**
 * Show a toaster witht message// w  ww .ja va 2 s .com
 * @param con
 * @param message
 */
public static void showToaster(Context con, String message) {
    Toast toast = Toast.makeText(con, message, Toast.LENGTH_LONG);
    toast.show();
}

From source file:Main.java

public static void makeShortToast(Context ctx, String message) {

    if (ctx != null && message != null) {

        Toast toast = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 50);
        toast.show();/*  w w w . ja va 2s  .  co m*/
    }
}

From source file:Main.java

public static void ShowToastCenter(Context context, String strText, int nTime) {
    if (context != null) {
        Toast toast = Toast.makeText(context, strText, nTime);

        toast.setGravity(Gravity.CENTER, 0, 0);

        toast.show();// ww w  . ja  v a  2 s  .  c  om
    }

}

From source file:Main.java

public static void showToast(Context context, String msg) {
    if (TextUtils.isEmpty(msg)) {
        return;//from  www .  j a  v a2  s  . c o  m
    }

    Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showTextToast(Context context, String msg) {
    if (toast == null) {
        toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    } else {/*from w w w.ja  v a2s  .  co  m*/
        toast.setText(msg);
    }
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();
}

From source file:Main.java

private static void showToast(Context context, String msg, int duration) {
    if (mToast != null)
        mToast.cancel();/*from w  w  w .j  a va2s.co m*/
    mToast = Toast.makeText(context, msg, duration);
    mToast.show();
}

From source file:Main.java

public static void showToast(Context c, String desc) {
    Toast.makeText(c, desc, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void gerarToast(CharSequence message, Context applicarionContext) {
    int duration = Toast.LENGTH_LONG;
    Toast toast = Toast.makeText(applicarionContext, message, duration);
    toast.show();/*from w  w  w.j av  a  2 s  . c o m*/
}

From source file:Main.java

public static void showCenterTextToast(Context context, String msg) {
    if (toast == null) {
        toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    } else {//from   w  w  w. j a  va2 s  . c  o m
        toast.setText(msg);
    }
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}