Example usage for android.widget Toast makeText

List of usage examples for android.widget Toast makeText

Introduction

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

Prototype

public static Toast makeText(Context context, @StringRes int resId, @Duration int duration)
        throws Resources.NotFoundException 

Source Link

Document

Make a standard toast that just contains a text view with the text from a resource.

Usage

From source file:Main.java

public static void showToast(@NonNull Context context, int resId) {
    Toast.makeText(context, context.getResources().getText(resId), Toast.LENGTH_SHORT).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  v a2 s . c om*/

    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

public static void showLongToast(Context mContext, @StringRes int resId) {
    Toast.makeText(mContext, resId, Toast.LENGTH_LONG).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 .ja  v a2 s.  c  o  m*/
    }

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

From source file:Main.java

public static void showShortToast(Context mContext, CharSequence text) {
    Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

/**
 * Show no Info alert dialog//from   ww  w.ja  v  a  2s.  co m
 *
 * @param context current Activity context
 * @param msg     message to be shown on the alert dialog
 */
public static void showNoInfoAlertToast(Activity context, Spanned msg) {
    Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
}

From source file:Main.java

static final void toastLong(String mesg) {
    if (null != curToast) {
        curToast.cancel();//from w  w  w .ja va 2s .c om
    }

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

From source file:Main.java

/**
 * Zeigt Positionierten Toast./*from  w  ww  .  j a v  a2 s .c o m*/
 * @param _Activity
 * @param _message  Darzustellende Nachricht
 * @param _Gravity  Position des Toasts
 */
public static void showPositionedToast(Activity _Activity, String _message, int _Gravity) {
    Toast toast = Toast.makeText(_Activity, _message, Toast.LENGTH_SHORT);
    toast.setGravity(_Gravity, 0, 120);
    toast.show();
}

From source file:Main.java

public static void showToast(Context context, String text, boolean isLong) {
    Toast.makeText(context, text, isLong ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
}