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 show(Context context, String text) {
    if (text == null) {
        text = "";
    }//from w w w  .  j a  v  a 2  s .c  o  m
    Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

static public void showToast(Context context, String msg) {
    Looper.prepare();
    Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
    Looper.loop();
}

From source file:Main.java

public static void mMakeTextToast(Activity activity, String str, boolean isLong) {
    if (isLong == true) {
        Toast.makeText(activity, str, Toast.LENGTH_LONG).show();
    } else {//from  w w  w . ja  va  2s.co  m
        Toast.makeText(activity, str, Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

public static void createToast(Context ctx, String value) {
    Toast toast = Toast.makeText(ctx, value, Toast.LENGTH_LONG);
    toast.show();
}

From source file:Main.java

public static void showShortToast(Context mContext, @StringRes int resId) {
    Toast.makeText(mContext, resId, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void ShowToastMessage(Context mContext, String xMessage) {
    Toast mToast = Toast.makeText(mContext, xMessage, Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.CENTER, 0, 0);
    mToast.show();/*  ww w.j  a va 2  s .c  om*/
}

From source file:Main.java

public static void checkNullStateByBoolean(Context context, boolean empty, String message) {
    if (empty) {/*from   w ww.  j a v a 2 s  . co  m*/
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
        throw new IllegalStateException(message);
    }
}

From source file:Main.java

public static void showToast(Context context, String message) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*ww w .  j  av  a 2  s. c  o m*/
}

From source file:Main.java

public static void toastShow(String msg) {
    if (myContext != null)
        Toast.makeText(myContext, msg, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void setToastView(Context context, String str) {
    Toast makeText = Toast.makeText(context, "   " + str + "   ", 0);
    TextView textView = (TextView) makeText.getView().findViewById(16908299);
    if (textView != null) {
        textView.setGravity(17);//w  w w.  j av a2s  .com
    }
    makeText.show();
}