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 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 w  w w.ja  va  2  s . c om*/
    }
}

From source file:Main.java

public static void showToast(final Context context, final String message) {
    if (mToast == null) {
        mToast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
    } else {/*w  ww  .  ja va  2 s  .com*/
        mToast.setText(message);
        mToast.setDuration(Toast.LENGTH_SHORT);
    }
    mToast.show();
}

From source file:Main.java

public static void showToast(Context c, String desc) {
    Toast.makeText(c, desc, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showToast(Context context, String msg) {
    if (TextUtils.isEmpty(msg)) {
        return;// www. j  a  v a2 s.  c  o  m
    }

    Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showTextToast(Context context, String msg) {
    if (toast == null) {
        toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    } else {/*  w  w  w  .  jav a2  s .c  om*/
        toast.setText(msg);
    }
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();
}

From source file:Main.java

public static void showCenterTextToast(Context context, String msg) {
    if (toast == null) {
        toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    } else {/*from w w  w  . j a v  a 2  s . co  m*/
        toast.setText(msg);
    }
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
}

From source file:Main.java

public static void showToast(Context context, String text) {
    if (toast == null) {
        toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    } else {//w  w w.ja  va 2s.com
        toast.setText(text);
    }
    toast.show();
}

From source file:Main.java

public static void showToast(Context mContext, String msg) {
    if (mToast == null) {
        mToast = Toast.makeText(mContext, "", Toast.LENGTH_SHORT);
    }//w  ww.  j  a  va2 s  .  c o m
    mToast.setText(msg);
    mToast.show();
}

From source file:Main.java

public static void showMessage(Context context, String msg) {
    if (context == null || TextUtils.isEmpty(msg)) {
        return;//from  w w w  . j  a va2  s . c  o  m
    }
    Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void popTipOrWarn(Context ctx, int txt) {
    Toast.makeText(ctx, txt, Toast.LENGTH_SHORT).show();
}