Example usage for android.widget Toast LENGTH_SHORT

List of usage examples for android.widget Toast LENGTH_SHORT

Introduction

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

Prototype

int LENGTH_SHORT

To view the source code for android.widget Toast LENGTH_SHORT.

Click Source Link

Document

Show the view or text notification for a short period of time.

Usage

From source file:Main.java

public static void showShortToast(Context mContext, CharSequence text) {
    Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

/**
 * This will display the message as a short toast
 * @param currentActivity - the activity you are calling this from
 * @param message - the message to display
 *///w  w  w .  jav  a  2s  .co  m
public static void toastShort(Context currentActivity, String message) {
    Toast.makeText(currentActivity, message, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showToast(Context context, String s) {
    if (toast == null) {
        toast = Toast.makeText(context, s, Toast.LENGTH_SHORT);
        toast.show();/*from  w  w  w  .j  a  v  a 2  s.  c o  m*/
        oneTime = System.currentTimeMillis();
    } else {
        twoTime = System.currentTimeMillis();
        if (s.equals(oldMsg)) {
            if (twoTime - oneTime > Toast.LENGTH_SHORT) {
                toast.show();
            }
        } else {
            oldMsg = s;
            toast.setText(s);
            toast.show();
        }
    }
    oneTime = twoTime;
}

From source file:Main.java

/**
 * Posts a new Toast/*  ww  w. j av  a  2s.c  om*/
 * 
 * @param context
 * @param text
 * @param duration
 */
public static void postToast(Context context, CharSequence text) {

    postToast(context, text, Toast.LENGTH_SHORT, Gravity.CENTER);
}

From source file:Main.java

/**
 * Zeigt Positionierten Toast./*from  ww  w.  j  av a  2  s  .com*/
 * @param _Activity
 * @param _message  Darzustellende Nachricht
 * @param _Gravity  Position des Toasts
 */
public static void showPositionedToast(Activity _Activity, String _message, int _Gravity) {
    Toast toast = Toast.makeText(_Activity, _message, Toast.LENGTH_SHORT);
    toast.setGravity(_Gravity, 0, 120);
    toast.show();
}

From source file:Main.java

public static void showTip(Context context, String text, boolean isInter) {
    if (null == showToast) {
        showToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    } else {// w  w  w .  ja  v a 2s. c o m
        if (isInter) {
            showToast.cancel();
            showToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        } else {
            showToast.setText(text);
        }
    }
    showToast.setGravity(Gravity.BOTTOM, 0, 0);
    showToast.show();
}

From source file:Main.java

/**
 * show short toast//  www .  j  a  va2  s.c o  m
 *
 * @param context : context
 * @param text    : the msg you will show
 */
public static void showShortToast(Context context, String text) {
    showImageToast(context, 0, text, Toast.LENGTH_SHORT);
}

From source file:Main.java

public static void toast(Context context, String message) {
    if (!TextUtils.isEmpty(message)) {
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
    }/*from  w ww. ja v a 2  s .  c o  m*/
}

From source file:Main.java

/**
 * show Toast//from   www.j a  va 2  s .c om
 *
 * @param context
 * @param message
 */
public static void showToast(Context context, String message) {
    if (TextUtils.isEmpty(message)) {
        return;
    }
    Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showClosableToast(Context context, String text, int duration) {

    if (staticToast != null)
        staticToast.cancel();//  w  ww.j  a  v  a2 s  .  c o  m

    staticToast = new Toast(context);

    switch (duration) {
    case 1:
        duration = Toast.LENGTH_SHORT;
        break;
    case 2:
        duration = Toast.LENGTH_LONG;
        break;
    }

    staticToast = Toast.makeText(context, text, duration);
    staticToast.show();
}