Example #1
0
        /// <summary>
        /// 显示自定义Toast提示
        /// </summary>
        /// <param name="mContext">M context.</param>
        /// <param name="iconResId">Icon res identifier.</param>
        /// <param name="words">Words.</param>
        private static void ShowMyToast(Context mContext, int iconResId, String words)
        {
            if (mToast != null)
            {
                if (Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.IceCreamSandwich)
                {
                    mToast.Cancel();
                }
            }

            mToast = MyToast.Create(mContext, iconResId, words, Android.Widget.ToastLength.Short);

            mToast.Show();
        }
Example #2
0
        public static MyToast Create(Context context, int iconResId, string msg, ToastLength duration)
        {
            View     wrap  = LayoutInflater.FromContext(context).Inflate(Resource.Layout.toast_bg, null);
            TextView tvMsg = (TextView)wrap.FindViewById(Resource.Id.tv_msg);

            tvMsg.SetText(msg, TextView.BufferType.Normal);
            ImageView ivIcon = (ImageView)wrap.FindViewById(Resource.Id.iv_icon);

            ivIcon.SetImageResource(iconResId);

            MyToast toast = new MyToast(context);

            toast.View = wrap;
            toast.SetGravity(GravityFlags.CenterVertical, 0, 0);
            toast.Duration = duration;
            return(toast);
        }