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

/**
 * Short toast message/*w  w w  .j ava 2s.  c  om*/
 *
 * @param context Application Context
 * @param msg Message to send
 */
public static void msgShort(Context context, String msg) {
    if (context != null && msg != null) {
        Toast.makeText(context, msg.trim(), Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

/**
 * Shows a short toast display//from  ww  w  . ja v a  2 s .c  o  m
 * 
 * @param ctx application context
 * @param message message to display
 */
public static void showToast(Context ctx, String message) {
    Toast toast = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();

}

From source file:Main.java

/**
 * Display a short toast/*from www  . j av a2s . c  o m*/
 * @param context to use
 * @param id of the string resource
 */
public static void toast(Context context, int id) {
    Toast toast = Toast.makeText(context, context.getString(id), Toast.LENGTH_SHORT);
    toast.show();
}

From source file:Main.java

public static void show(String text) {
    if (sToast == null) {
        sToast = Toast.makeText(sContext, text, Toast.LENGTH_SHORT);
    } else {//w  w w.  ja v  a  2 s .c  o m
        sToast.setText(text);
    }
    sToast.show();
}

From source file:Main.java

public static void showToast(Context context, String toastStr) {
    if ((g_Toast == null) || (g_Toast.getView().getWindowVisibility() != View.VISIBLE)) {
        g_Toast = Toast.makeText(context, toastStr, Toast.LENGTH_SHORT);
        g_Toast.show();/*from ww  w . ja  va 2s  .  c  o  m*/
    }

    return;
}

From source file:Main.java

/**
 * show a toast/* w w w .  ja  v a  2  s.co  m*/
 * @param context
 * @param resId the content that to be display
 */
public static void getToast(Context context, int resId) {
    if (null == sToast) {
        sToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    }
    sToast.setText(resId);
    sToast.show();
}

From source file:Main.java

public static void showPercentToast(boolean show, Activity a, SharedPreferences prefs, double brightness) {

    if (percentToast == null) {
        percentToast = Toast.makeText(a, "", Toast.LENGTH_SHORT);
    }//from ww  w.j a  va  2 s  .com

    percentToast.setText(new Integer((int) (brightness / 2.55)).toString() + "%");

    if (show) {
        if (prefs.getBoolean("showToast", true))
            percentToast.show();
    } else {
        percentToast.cancel();
    }
}

From source file:Main.java

/**
 * Display toast message//from  w w w  .  j a v  a2  s .  c  om
 *
 * @param context application context
 * @param message the message to be displayed
 * */
public static void showToast(Context context, String message) {
    mToast.makeText(context, message, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

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

From source file:Main.java

static final void toast(String mesg) {
    if (null != curToast) {
        curToast.cancel();//from  w  w  w . j  a  v  a 2  s  .  c  o m
    }

    curToast = Toast.makeText(curContext, mesg, Toast.LENGTH_SHORT);
    curToast.show();
}