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 DisplayToast(Context context, String text) {
    Toast toast;
    toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}

From source file:Main.java

public static void makeShortToast(Context ctx, String message) {

    if (ctx != null && message != null) {

        Toast toast = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 50);
        toast.show();
    }/*from   www  .ja va 2s .  com*/
}

From source file:Main.java

/**Toast dialog with string */
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();

}

From source file:Main.java

public static void showLToast(Context context, int resId) {
    Toast toast = Toast.makeText(context, resId, Toast.LENGTH_LONG);
    ;/*from w w  w. j  av a 2  s .  c  o  m*/
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}

From source file:Main.java

public static void showMessage(Context context, String msg) {
    Toast toast = Toast.makeText(context.getApplicationContext(), msg, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}

From source file:Main.java

/**
 * Posts a new Toast//  w  ww. jav a 2 s  .c o m
 * 
 * @param context
 * @param text
 * @param duration
 * @param gravity
 */
public static void postToast(Context context, CharSequence text, int duration, int gravity) {

    duration = duration == 0 ? Toast.LENGTH_LONG : duration;
    Toast toast = Toast.makeText(context, text, duration);
    toast.setGravity(gravity, 0, 0);
    toast.show();
}

From source file:Main.java

/**
 * Make long toast./*w w  w . j av a 2  s .c  o  m*/
 *
 * @param ctx     the ctx
 * @param message the message
 */
public static void makeLongToast(Context ctx, String message) {

    if (ctx != null && message != null) {

        Toast toast = Toast.makeText(ctx, message, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 50);
        toast.show();
    }
}

From source file:Main.java

public static void showToast(Context context, String title) {
    Toast toast = Toast.makeText(context, title, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}

From source file:Main.java

public static void showToastShort(Context context, String message) {
    Toast toast = Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}

From source file:Main.java

public static void showToast(String message, Context context, int duration) {
    if (message == null || message.length() == 0)
        return;//from w w  w  . jav a  2s . c o m

    try {
        Toast toast = Toast.makeText(context, message, duration);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    } catch (Exception e) {
        //
    }
}