List of usage examples for android.widget Toast Toast
public Toast(Context context)
From source file:Main.java
public static void longToast(int string, Context ctx) { Toast t = new Toast(ctx).makeText(ctx, string, Toast.LENGTH_LONG); t.setGravity(Gravity.TOP, 0, dpToPx(55, ctx)); t.show();/*from www . j av a 2s . co m*/ }
From source file:Main.java
public static void shortToast(int string, Context ctx) { Toast t = new Toast(ctx).makeText(ctx, string, Toast.LENGTH_SHORT); t.setGravity(Gravity.TOP, 0, dpToPx(55, ctx)); t.show();//from ww w.j av a2s. c o m }
From source file:Main.java
public static void showToast(Context context, int id) { if (mToast == null) { mToast = new Toast(context); mToast.setText(id);//from w w w . j ava 2s . c o m } mToast.show(); }
From source file:Main.java
private static void getToast(int duration) { if (mToast == null) { mToast = new Toast(mContext); mToast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); mToast.setDuration(duration);//from ww w . ja v a 2s. c o m } }
From source file:Main.java
public static void showClosableToast(Context context, String text, int duration) { if (staticToast != null) staticToast.cancel();/* www. jav a 2 s. c om*/ 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
@SuppressLint("ShowToast") private static void getToast(Context context) { if (toast == null) { toast = new Toast(context); }// w w w . j a v a 2 s . c o m if (view == null) { view = Toast.makeText(context, "", Toast.LENGTH_SHORT).getView(); } toast.setView(view); }
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 ww. java 2 s . c o m*/ 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(); }
From source file:Main.java
public static void showToast(Context context, String string) { if (mToast == null) { mToast = new Toast(context); mToast.setText(string);/*from ww w. jav a2 s. c om*/ } mToast.show(); }
From source file:Main.java
/** * Creates a custom {@link Toast} with a custom layout View * /* w w w. j a v a 2 s . com*/ * @param context * the context * @param resId * the custom view * @return the created {@link Toast} */ public static Toast makeCustomToast(Context context, int resId) { View view = LayoutInflater.from(context).inflate(resId, null); Toast t = new Toast(context); t.setDuration(Toast.LENGTH_SHORT); t.setView(view); t.setGravity(Gravity.CENTER, 0, 0); return t; }
From source file:Main.java
public static void showToast(Context context, View view) { Toast toast = new Toast(context); toast.setView(view);//from w w w.j a v a 2 s . co m toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.show(); }