Example usage for android.widget Toast show

List of usage examples for android.widget Toast show

Introduction

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

Prototype

public void show() 

Source Link

Document

Show the view for the specified duration.

Usage

From source file:com.vel9studios.levani.popularmovies.util.AppUtils.java

public static void displayFavoritesMessage(String favoriteFlag, String movieTitle, Context context) {

    String favoriteMessage = "";
    if (favoriteFlag.equals(AppConstants.Y_FLAG))
        favoriteMessage = movieTitle + AppConstants.MESSAGE_FAVORITE_ADDED;
    else if (favoriteFlag.equals(AppConstants.N_FLAG))
        favoriteMessage = movieTitle + AppConstants.MESSAGE_FAVORITE_REMOVED;

    Toast appStart = Toast.makeText(context, favoriteMessage, Toast.LENGTH_SHORT);
    appStart.show();
}

From source file:Main.java

public static void toastGreen(Activity activity, int resId) {
    Toast toast = Toast.makeText(activity, resId, Toast.LENGTH_LONG);
    TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
    v.setBackgroundColor(Color.GREEN);
    toast.show();

}

From source file:Main.java

/**
 * @param message//www . j  a va  2  s  .  c om
 */
public static void showToast(int message, Toast mToast, Context context) {
    if (mToast == null) {
        mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
    }
    mToast.setText(context.getString(message));
    mToast.show();
}

From source file:Main.java

public static void showShortToastBottom(Context context, int resId) {
    Toast toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    TextView v = toast.getView().findViewById(android.R.id.message);
    if (v != null)
        v.setGravity(Gravity.CENTER);/*from  w ww.  ja v  a2s.c om*/
    toast.show();
}

From source file:Main.java

public static Toast alert(Context ctx, int nResID) {
    Toast t = Toast.makeText(ctx, nResID, Toast.LENGTH_SHORT);
    TextView v = (TextView) t.getView().findViewById(android.R.id.message);
    if (v != null)
        v.setGravity(Gravity.CENTER);//from w w  w  . j av a  2 s .c  om
    t.show();

    return t;
}

From source file:Main.java

public static Toast alert(Context ctx, String message) {
    Toast t = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
    TextView v = (TextView) t.getView().findViewById(android.R.id.message);
    if (v != null)
        v.setGravity(Gravity.CENTER);/*ww w .  j av a 2  s.c  om*/
    t.show();

    return t;
}

From source file:Main.java

public static void setToastView(Context context, String str) {
    Toast makeText = Toast.makeText(context, "   " + str + "   ", 0);
    TextView textView = (TextView) makeText.getView().findViewById(16908299);
    if (textView != null) {
        textView.setGravity(17);/*from  w ww. ja v a2  s. c  o m*/
    }
    makeText.show();
}

From source file:Main.java

public static void showCenteredToast(Context context, CharSequence text, int duration) {
    Toast toast = Toast.makeText(context, text, duration);
    TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
    if (v != null) {
        v.setGravity(Gravity.CENTER);//from  ww w .jav  a  2  s. c  o m
    }
    toast.show();
}

From source file:Main.java

public static void showCenteredToast(Context context, int resId, int duration) {
    Toast toast = Toast.makeText(context, resId, duration);
    TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
    if (v != null) {
        v.setGravity(Gravity.CENTER);//  ww w . j a v a 2s.  c o m
    }
    toast.show();
}

From source file:Main.java

public static void toastShow(String paramString, Context paramContext) {
    View localView = LayoutInflater.from(paramContext).inflate(getLayoutId(paramContext, "xdw_toast_item"),
            null);//w  w  w .  j  av a  2  s. c  om
    Toast localToast = new Toast(paramContext);
    localToast.setView(localView);
    localToast.setGravity(17, 0, 0);
    ((TextView) localView.findViewById(getResId(paramContext, "xdw_toast_mes"))).setText(paramString);
    localToast.show();
}