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 toast(Context context, final String msg) {
    try {/*from  w ww . j a  v  a2s . co  m*/
        Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
        Log.d(TAG, "toast: " + msg);
    } catch (Exception e) {
        Log.d(TAG, "Couldn't display toast: " + msg + " / " + e.toString());
    }
}

From source file:Main.java

/**
 * Zeigt einen Toast an//from w  ww .  j  a  v  a 2s.  co  m
 * @param text Anzuzeigender Text
 * @param context
 */
public static void showToast(String text, Context context) {
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(context, text, duration);
    toast.show();
}

From source file:Main.java

public static void toast(Context c, String msg) {
    if (s_toast != null) {
        s_toast.cancel();//from   ww  w  . j a  va 2  s.  c o  m
    }
    s_toast = Toast.makeText(c, msg, Toast.LENGTH_SHORT);
    s_toast.show();
}

From source file:Main.java

public static void showToastShort(Context context, String text) {
    Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void toast(Context context, int resId) {
    Toast.makeText(context, resId, Toast.LENGTH_LONG).show();
}

From source file:Main.java

/**
 * Show toast.//from w w  w  .j ava  2  s .  c  om
 * 
 * @param appContext
 *            the app context
 * @param message
 *            the message
 */
public static void showToast(Context appContext, String message) {

    Toast.makeText(appContext, message, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

/**
 * This method provides uniform logging functionality for given message
 * @param context/*from   ww  w  . j  a v  a2s  .c  o m*/
 * @param errmsg
 */
public static void handleError(Context context, String errmsg) {
    Toast.makeText(context, errmsg, Toast.LENGTH_LONG).show();
    Log.e("Yum Exception!", errmsg);
}

From source file:Main.java

/**
 * Display a short toast//  ww  w .java2  s.  c o m
 * @param context to use
 * @param id of the string resource
 */
public static void toast(Context context, int id) {
    Toast toast = Toast.makeText(context, context.getString(id), Toast.LENGTH_SHORT);
    toast.show();
}

From source file:Main.java

@SuppressLint("ShowToast")
public static Toast createToast(Context context, String message) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0);
    return toast;
}

From source file:Main.java

/**
 * Shows a long toast message// w  w w. ja va  2 s . co m
 *
 * @param context Context that toast should be visible in
 * @param message String to be shown
 */
public static void showToastLong(Context context, String message) {
    Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}