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

/**
 * show a toast/*from  ww  w . j  a v a 2 s  . c  o  m*/
 * @param context
 * @param resId the content that to be display
 */
public static void getToast(Context context, int resId) {
    if (null == sToast) {
        sToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    }
    sToast.setText(resId);
    sToast.show();
}

From source file:Main.java

public static void showMessage(Context context, String message) {
    Toast.makeText(context, message, Toast.LENGTH_LONG).show();
}

From source file:Main.java

@SuppressLint("ShowToast")
public synchronized static Toast getInstance(Context context, String text, int duration) {
    if (null == mToast) {
        mToast = Toast.makeText(context.getApplicationContext(), text, duration);
    } else {//  w  ww  . ja  v a  2 s.  c om
        mToast.setText(text);
        mToast.setDuration(duration);
    }
    return mToast;
}

From source file:Main.java

/**
 * This will display the message as a long toast
 * @param currentActivity - the activity you are calling this from
 * @param message - the message to display
 *///w  w  w . ja  v  a2s .  c o m
public static void toastLong(Context currentActivity, String message) {
    Toast.makeText(currentActivity, message, Toast.LENGTH_LONG).show();
}

From source file:Main.java

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

From source file:Main.java

public static void showToast(Context context, String message, int duration) {
    Toast.makeText(context, message, duration).show();
}

From source file:Main.java

/**
 * This method provides uniform exception handling functionality
 * @param context//from  w w  w.  ja va 2  s. c  om
 * @param e
 * @param errmsg
 */
public static void handleException(Context context, Exception e, String errmsg) {
    Toast.makeText(context, "(e) " + errmsg, Toast.LENGTH_LONG).show();
    Log.e("Yum Exception!", errmsg);
    Log.e("Yum Exception!", e.toString());
}

From source file:Main.java

protected static void showToast(Context context, String msg, int length) {
    Toast toast = Toast.makeText(context, msg, length);
    toast.show();
}

From source file:Main.java

/**
 * show Toast/*from  w  w w .j  a  v  a  2  s  .c o  m*/
 *
 * @param context
 * @param message
 */
public static void showToast(Context context, String message) {
    if (TextUtils.isEmpty(message)) {
        return;
    }
    Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

/**
 * This will display the message as a short toast
 * @param currentActivity - the activity you are calling this from
 * @param message - the message to display
 *//*from www.  java  2s.c  om*/
public static void toastShort(Context currentActivity, String message) {
    Toast.makeText(currentActivity, message, Toast.LENGTH_SHORT).show();
}