List of usage examples for android.widget Toast setView
public void setView(View view)
From source file:Main.java
public static void showToast(Context context, View view) { Toast toast = new Toast(context); toast.setView(view); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.show();// w w w . j a v a 2 s . c o m }
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 2s.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(); }
From source file:Main.java
/** * Creates a custom {@link Toast} with a custom layout View * // w w w .j av a2 s . c om * @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 showToastView(Context context, String text) { Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT); View view = toast.getView();/*from w w w .ja v a2 s. com*/ view.setBackgroundColor(Color.GREEN); toast.setView(view); toast.show(); }
From source file:com.github.rutvijkumar.twittfuse.Util.java
public static void showNetworkUnavailable(Activity activity) { LayoutInflater inflater = activity.getLayoutInflater(); View view = inflater.inflate(R.layout.network_not_available, (ViewGroup) activity.findViewById(R.id.nwunavailable)); Toast toast = new Toast(activity); toast.setView(view); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.show();/*w ww. j a v a2 s .com*/ }
From source file:org.wahtod.wififixer.utility.NotifUtil.java
public static void showToast(Context context, String message, int delay) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.toast, null); ImageView image = (ImageView) layout.findViewById(R.id.icon); image.setImageResource(R.drawable.icon); TextView text = (TextView) layout.findViewById(R.id.text); text.setText(message);//from ww w .j a v a2 s.c o m Toast toast = new Toast(context.getApplicationContext()); toast.setGravity(Gravity.BOTTOM | Gravity.CENTER, 0, 0); toast.setDuration(delay); toast.setView(layout); toast.show(); }
From source file:de.baumann.hhsmoodle.helper.helper_main.java
public static void makeToast(Activity activity, String Text) { LayoutInflater inflater = activity.getLayoutInflater(); View toastLayout = inflater.inflate(R.layout.toast, (ViewGroup) activity.findViewById(R.id.toast_root_view)); TextView header = (TextView) toastLayout.findViewById(R.id.toast_message); header.setText(Text);//from w w w .ja va 2s. c o m Toast toast = new Toast(activity.getApplicationContext()); toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(toastLayout); toast.show(); }
From source file:com.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast.//from w ww .j a v a 2s .c o m * * @param context the context * @param view the view */ public static void showCustomToast(Context context, View view) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Toast.LENGTH_LONG); newCustomToast.show(); }
From source file:com.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast.//from w ww . j a v a 2 s . c o m * * @param context the context * @param view the view * @param Duration the duration e.g <code>Toast.LENGTH_SHORT</code> , <code>Toast.LENGTH_LONG</code> */ public static void showCustomToast(Context context, View view, int Duration) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Duration); newCustomToast.show(); }
From source file:com.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast./* ww w. ja v a2 s . c om*/ * * @param context the context * @param view the view * @param gravity the gravity e.g <code>GRAVITY.BOTTOM</code> , <code>GRAVITY.CENTER_VERTICAL</code> , etc * @param xoffset the x offset * @param yoffset the y offset */ public static void showCustomToast(Context context, View view, int gravity, int xoffset, int yoffset) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Toast.LENGTH_LONG); newCustomToast.setGravity(gravity, xoffset, yoffset); newCustomToast.show(); }