Example usage for android.widget Toast LENGTH_LONG

List of usage examples for android.widget Toast LENGTH_LONG

Introduction

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

Prototype

int LENGTH_LONG

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

Click Source Link

Document

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

Usage

From source file:Main.java

/**
 * show long toast/*from  w ww  .j a  va  2s  .  c om*/
 * See{@link #showImageToast(Context, int, String, int)}
 *
 * @param context :context
 * @param text    :the msg you will show
 */
public static void showLongToast(Context context, String text) {
    showImageToast(context, 0, text, Toast.LENGTH_LONG);
}

From source file:Main.java

public static void showMsg(final Activity act, final String msg, final boolean isLongShow) {
    act.runOnUiThread(new Runnable() {
        @Override/*from  w w  w.ja  v  a  2s.c  om*/
        public void run() {
            // TODO Auto-generated method stub
            if (isLongShow) {
                Toast.makeText(act, msg, Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(act, msg, Toast.LENGTH_SHORT).show();
            }
        }
    });
}

From source file:Main.java

private static void showToast(final Context context, final String string) {
    Handler handler = new Handler(Looper.getMainLooper());

    handler.post(new Runnable() {

        @Override/* w ww.  j  av a  2 s  . c o m*/
        public void run() {
            Toast.makeText(context, string, Toast.LENGTH_LONG).show();

        }
    });
}

From source file:Main.java

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

    if (staticToast != null)
        staticToast.cancel();//from  w w  w  . j  a va  2  s.com

    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();
}

From source file:Main.java

public static void showLongToast(final Context mContext, final int resId) {
    sharedHandler(mContext).post(() -> {
        if (toast != null) {
            toast.setText(resId);/*w w w. j a  va 2  s . c  om*/
            toast.setDuration(Toast.LENGTH_LONG);
        } else {
            toast = Toast.makeText(mContext.getApplicationContext(), resId, Toast.LENGTH_LONG);
        }
        toast.show();
    });
}

From source file:Main.java

/**Toast dialog with string */
public static void showToast(final String message, final Activity activity) {
    final Toast toast = Toast.makeText(activity, message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();/*from  w  w  w .  j a  v a 2  s .  c  om*/

}

From source file:Main.java

public static void ShowToast(Context cxt, String str, boolean isLong) {
    if (isLong) {
        Toast.makeText(cxt, str, Toast.LENGTH_LONG).show();
    } else {/*  w w w .  j a  v  a  2 s . c  o  m*/
        Toast.makeText(cxt, str, Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

/**
 * show long image toast// w w  w . ja  v a  2s  . c  o  m
 * See{@link #showImageToast(Context, int, String, int)}
 *
 * @param context    :context
 * @param ImageResId :imageres id
 * @param text       :the msg you will show
 */

public static void showLongImageToast(Context context, int ImageResId, String text) {
    showImageToast(context, ImageResId, text, Toast.LENGTH_LONG);
}

From source file:Main.java

public static void showLong(Context context, @StringRes int resId) {
    if (context != null) {
        Toast.makeText(context.getApplicationContext(), resId, Toast.LENGTH_LONG).show();
    }/*from   ww  w .j av a  2 s  .c o m*/
}

From source file:Main.java

public static void toast(final String text) {
    Activity a = activity.get();// w  w  w .  ja va2 s.c  o m
    if (a == null) {
        return;
    }
    a.runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(context, text, Toast.LENGTH_LONG).show();
        }
    });
}