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 toastMessage(Context context, int res) {
    Toast.makeText(context, res, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showToastView(Context context, String text) {
    Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    View view = toast.getView();/*from  ww w.  ja va 2  s . com*/
    view.setBackgroundColor(Color.GREEN);
    toast.setView(view);
    toast.show();
}

From source file:Main.java

public static void showToast(Context context, String text) {
    if (mToast == null) {
        mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
    }/* w w  w .j av  a 2 s.c o  m*/
    mToast.setText(text);
    mToast.show();
}

From source file:Main.java

public static void showWaningToast(Context context, String str) {
    if (context == null)
        return;// w  w  w .  jav a 2  s .  c om
    try {
        Toast.makeText(context, str, Toast.LENGTH_LONG).show();
    } catch (Exception e) {
    }
}

From source file:Main.java

public static void ShowTips(Context context, String tips) {
    if (mToast == null) {
        mToast = Toast.makeText(context, tips, Toast.LENGTH_SHORT);
    } else {//www. j a v a2 s  . com
        mToast.setText(tips);
    }
    mToast.show();
}

From source file:Main.java

public static void showToast(Context context, String msg) {
    if (mToast == null) {
        mToast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    } else {/*w ww.  java  2s . c o m*/
        mToast.setText(msg);
    }
    mToast.show();
}

From source file:Main.java

public static void toastGreen(Activity activity, int resId) {
    Toast toast = Toast.makeText(activity, resId, Toast.LENGTH_LONG);
    TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
    v.setBackgroundColor(Color.GREEN);
    toast.show();/*from   ww w .j ava  2  s  .c o  m*/

}

From source file:Main.java

public static void show(Context context, String text) {
    if (toast == null) {
        toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    } else {/*from  w ww .  j av a2 s  .  c  o m*/
        toast.setText(text);
    }
    toast.show();
}

From source file:Main.java

/**
 * Toast/*from   w ww  .  ja  v  a 2s .c o  m*/
 * 
 * @param mContext
 * @param text
 */
public static void sendToast(Context mContext, String text) {
    Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showTextLong(Context context, String text) {
    if (toast == null) {
        toast = Toast.makeText(context, text, Toast.LENGTH_LONG);
    } else {//from w  w w.  j  a v  a2 s  .  co m
        toast.setText(text);
        toast.setDuration(Toast.LENGTH_LONG);
    }
    toast.show();
}