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 showToast(Context context, String text) {
    // TODO Auto-generated method stub
    Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showToast(final String toast, final Context context) {
    new Thread(new Runnable() {

        @Override/*  w w w . j av a 2  s .  c om*/
        public void run() {
            Looper.prepare();
            Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
            Looper.loop();
        }
    }).start();
}

From source file:Main.java

public static void show(Context context, int info) {
    Toast.makeText(context, info, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

/**
 * Shows toast for short duration// ww w.  jav  a 2s .  c o m
 */
public static void toastShort(Context context, String msg) {
    if (context == null)
        return;

    if (toastShort != null)
        toastShort.cancel();
    toastShort = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    toastShort.show();
}

From source file:Main.java

public static void showToast(@NonNull Context context, int resId) {
    Toast.makeText(context, context.getResources().getText(resId), Toast.LENGTH_SHORT).show();
}

From source file:Main.java

/**
 * showToast/*  www . java 2 s .c o m*/
 * @param context
 * @param message
 * @param duration    LENGTH_SHORT,LENGTH_LONG
 */
public static void showToastTips(Context context, String message, int duration) {
    if (!TextUtils.isEmpty(message)) {
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

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

    Handler handler = new Handler(Looper.getMainLooper());

    handler.post(new Runnable() {

        @Override//from   ww w  .j  a  v a 2 s .  co m
        public void run() {
            Toast.makeText(context, s, Toast.LENGTH_SHORT).show();

        }
    });
}

From source file:Main.java

/**
 * Shows long toast message on screen/*from   w w w .j a v a 2s  . co  m*/
 */
public final static void showToastMessage(CharSequence message, Boolean durationLong, Context activityContext) {
    Toast toast;
    int duration;

    if (durationLong) {
        duration = Toast.LENGTH_LONG;
    } else {
        duration = Toast.LENGTH_SHORT;
    }

    toast = Toast.makeText(activityContext, message, duration);
    toast.show();
}

From source file:Main.java

public static Toast showShort(Context context, @StringRes int showText) {
    return show(context, showText, Toast.LENGTH_SHORT);
}

From source file:Main.java

public static void showToast(Context context, String text, boolean isLong) {
    Toast.makeText(context, text, isLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
}