Beispiel #1
0
        public override ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View itemView = LayoutInflater.From(parent.Context).
                            Inflate(Resource.Layout.product_view, parent, false);

            ProductViewHolder vh = new ProductViewHolder(itemView, OnClick);

            return(vh);
        }
Beispiel #2
0
        public override void OnBindViewHolder(ViewHolder holder, int position)
        {
            ProductViewHolder vh = holder as ProductViewHolder;

            vh.Image.SetImageDrawable(_context.GetDrawable(Resource.Drawable.ic_material_product_icon)); // placeholder
            vh.Image.ImageFromUrlAsync(products[position].Image);
            vh.ProductName.Text  = products[position].Name;
            vh.ProductPrice.Text = products[position].Price.ToString("C", products[position].GetCulture());
            if (products[position].IsOnSale)
            {
                vh.ProductPrice.SetTextColor(vh.OnSaleLabel.TextColors);
                vh.OnSaleLabel.Visibility = ViewStates.Visible;
            }
            else
            {
                vh.OnSaleLabel.Visibility = ViewStates.Gone;
            }
        }