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

public static void show(Context context, int info, boolean longtoast) {
    if (longtoast) {
        Toast.makeText(context, info, Toast.LENGTH_LONG).show();
    } else {// w  ww  .  j a v  a2s. co m
        Toast.makeText(context, info, Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

public static void showLongToast(final Context mContext, final String text) {
    sharedHandler(mContext).post(() -> {
        if (toast != null) {
            toast.setText(text);//from www .jav a2 s  . com
            toast.setDuration(Toast.LENGTH_LONG);
        } else {
            toast = Toast.makeText(mContext.getApplicationContext(), text, Toast.LENGTH_LONG);
        }
        toast.show();
    });
}

From source file:Main.java

/**
 * Shows a (long) toast.//from w ww  .  j  av a2s  .c o  m
 *
 * @param context
 * @param resourceId
 */
public static void showToast(Context context, int resourceId) {
    Toast.makeText(context, context.getString(resourceId), Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void showFailure(Context ctx, int id) {
    Toast.makeText(ctx, ctx.getResources().getString(id), Toast.LENGTH_LONG).show();
}

From source file:Main.java

static void showLongToastMessage(Context context, int messageId) {
    Toast.makeText(context, messageId, Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void showFailure(Activity activity, int id) {
    Toast.makeText(activity, activity.getResources().getString(id), Toast.LENGTH_LONG).show();
}

From source file:Main.java

/**
 * Posts a new Toast/*from  w  w w .  ja  v a2s.co m*/
 * 
 * @param context
 * @param text
 * @param duration
 * @param gravity
 */
public static void postToast(Context context, CharSequence text, int duration, int gravity) {

    duration = duration == 0 ? Toast.LENGTH_LONG : duration;
    Toast toast = Toast.makeText(context, text, duration);
    toast.setGravity(gravity, 0, 0);
    toast.show();
}

From source file:Main.java

public static void endAppFailure(Activity activity, int id) {
    Toast.makeText(activity, activity.getResources().getString(id), Toast.LENGTH_LONG).show();
    activity.finish();// ww  w  . j  a va  2s.  com
}

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 www. ja va2 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 displayMessage(Activity contextActivity, String messageId) {
    Toast.makeText(contextActivity, messageId, Toast.LENGTH_LONG).show();
}