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

static void showShortToastMessage(Context context, String message) {
    Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

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

From source file:Main.java

public static void showToast(String message, Context context) {
    showToast(message, context, Toast.LENGTH_SHORT);
}

From source file:Main.java

/**
 * copy plain text to clip board/*  w w  w  . j av a2s .c om*/
 *
 * @param context
 * @param tag
 * @param text
 * @param toastText may null, no toast at all
 */
public static void copy2ClipBoard(Context context, String tag, String text, String toastText) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText(tag, text);
    clipboard.setPrimaryClip(clip);
    if (toastText != null) {
        Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

public static final void showToast(Context context, String tip, boolean isCenter) {
    int duration = Toast.LENGTH_SHORT;
    if (TextUtils.isEmpty(tip)) {
        return;/*from  w  w w  .j  av a  2 s .c  o m*/
    }
    if (tip.length() >= 15) {
        duration = Toast.LENGTH_LONG;
    }
    Toast toast = Toast.makeText(context, tip, duration);
    if (isCenter) {
        toast.setGravity(Gravity.CENTER, 0, 0);
    }
    toast.show();
}

From source file:Main.java

public static void shortT(Context context, CharSequence text) {
    createToast(context);//from   ww w.j a va  2s. c  o m
    sToast.setDuration(Toast.LENGTH_SHORT);
    sToast.setText(text);
    sToast.show();
}

From source file:Main.java

public static void showToast(Context context, String message) {
    Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_SHORT).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();//  w  w  w  .j a v a  2s  .c o m
}

From source file:Main.java

public static final void toastMessage(final Activity activity, final String message, String logLevel) {
    if ("w".equals(logLevel)) {
        Log.w("sdkDemo", message);
    } else if ("e".equals(logLevel)) {
        Log.e("sdkDemo", message);
    } else {//from w w  w .  j a  v  a2  s  .com
        Log.d("sdkDemo", message);
    }
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            // TODO Auto-generated method stub
            if (mToast != null) {
                mToast.cancel();
                mToast = null;
            }
            mToast = Toast.makeText(activity, message, Toast.LENGTH_SHORT);
            mToast.show();
        }
    });
}

From source file:Main.java

public static void ToastMsg(Context context, int resourceId) {
    if (context == null) {
        return;//from  w w  w.j a  v  a 2  s .c  o m
    }
    if (mToast != null) {
        mToast.cancel();
        mToast = null;
    }
    mToast = Toast.makeText(context, resourceId, Toast.LENGTH_SHORT);
    mToast.show();
}