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 showToastNotification(final String msg, final Activity activity) {
    if (activity == null)
        return;//  w  w w .  j  av a 2  s .  c  om

    activity.runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
        }
    });

}

From source file:Main.java

/**
 * Short toast message/*from w  ww  .  j a v a  2 s.  com*/
 *
 * @param c Application Context
 * @param msg Message to send
 */
public static void msgShort(final Context c, final String msg) {
    if (c != null && msg != null) {
        Toast.makeText(c, msg.trim(), Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

/**
 * Function to display toast message to user
 *
 * @param context:context of the activity
 * @param msg:message     to display to the user
 */// w w w.  j  a  v a2s  .c  o m
public static void displayToast(Context context, String msg) {
    Toast.makeText(context, msg, Toast.LENGTH_LONG).show();

}

From source file:Main.java

public static void showToast(Context context, int resId) {

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

From source file:Main.java

private static void toast(Context context, int msgRes, int lenth) {
    Toast.makeText(context, msgRes, lenth).show();
}

From source file:Main.java

/**
 * Short toast message/*  w  ww  .jav a2 s .  c  om*/
 *
 * @param context Application Context
 * @param msg Message to send
 */
public static void msgShort(Context context, String msg) {
    if (context != null && msg != null) {
        Toast.makeText(context, msg.trim(), Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

public static void showToast(Context mContext, String text) {
    if (toast == null) {
        toast = Toast.makeText(mContext, text, Toast.LENGTH_SHORT);
    } else {//from w ww  .  j ava2  s  .c  o m
        toast.setText(text);
    }

    handler.post(new Runnable() {

        @Override
        public void run() {
            toast.show();
        }
    });
}

From source file:Main.java

/**
 * shows a toast//from ww w .ja  v  a2  s  . co  m
 *
 * @param context context of calling activity
 * @param text    text to be displayed
 */
public static void showToast(Context context, String text) {
    Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void makeToast(Context context, String text, int type) {
    int duration = 0;
    if (type == 0) {
        duration = Toast.LENGTH_SHORT;//from ww w . ja  va2s .co m
    } else {
        duration = Toast.LENGTH_LONG;
    }
    Toast.makeText(context, text, duration).show();
}

From source file:Main.java

public static void showErrorMessage(Context context, int message, Object... args) {
    Toast.makeText(context, context.getString(message, args), Toast.LENGTH_LONG).show();
}