Example usage for android.widget Toast show

List of usage examples for android.widget Toast show

Introduction

In this page you can find the example usage for android.widget Toast show.

Prototype

public void show() 

Source Link

Document

Show the view for the specified duration.

Usage

From source file:Main.java

public static void showToast(Context context, String text, int duration) {
    Toast toast = Toast.makeText(context, text, duration);
    toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
    toast.show();
}

From source file:Main.java

public static void showToast(Context c, String str) {
    Toast toast = Toast.makeText(c, str, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, toast.getXOffset() / 2, toast.getYOffset() / 2);
    toast.show();
}

From source file:Main.java

public static void ShowToast(Context context, String message) {
    Toast msg = Toast.makeText(context, message, Toast.LENGTH_SHORT);
    msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2);
    msg.show();
}

From source file:Main.java

public static void toast(String message, Context context) {
    Toast msg = Toast.makeText(context, message, Toast.LENGTH_LONG);
    msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2);
    msg.show();
}

From source file:Main.java

public static void centerToast(Context context, String message) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0);
    toast.show();
}

From source file:Main.java

public static void showToast(final Context context, final String s) {

    if (Looper.getMainLooper() == Looper.myLooper()) {
        Toast toast = Toast.makeText(context, s, Toast.LENGTH_SHORT);
        hideToast();/*from ww  w.  ja v  a  2s  . c  o m*/
        toast.show();
        sToastRef = new SoftReference<Toast>(toast);
    } else {
        if (context instanceof Activity) {
            ((Activity) context).runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    showToast(context, s);
                }
            });
        }
    }
}

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_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
    toast.show();
}

From source file:Main.java

public static void ShowToast(Context context, String strMsg) {
    Toast toast = Toast.makeText(context, strMsg, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(1000);/*from ww  w .jav  a2s . co  m*/
    toast.show();
}

From source file:Main.java

/**
 * Toast dialog with string/* w  w  w  .  jav a  2s  . c  om*/
 */
public static void showToast(final String message, final Context context) {
    final Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();
}

From source file:Main.java

/**
 * Toast dialog with string/*from w w w.ja  va 2  s  .  c o m*/
 */
public static void showToast(final String message, final Activity activity) {
    final Toast toast = Toast.makeText(activity, message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();
}