public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { // loads the data at the specified position into the views whose // references are stored in the given view holder AlimentoEstabelecimento alimentoEstabelecimento = Resultados[position]; ResultadoViewHolder vh = holder as ResultadoViewHolder; byte[] foto = alimentoEstabelecimento.Alimento.Foto; float? preco = alimentoEstabelecimento.Alimento.Preco; // Campos opcionais if (foto != null) { vh.FoodImage.SetImageBitmap(BitmapFactory.DecodeByteArray(foto, 0, foto.Length)); } if (preco.HasValue) { vh.Price.Text = preco + "€"; } // Campos obrigatórios vh.FoodName.Text = alimentoEstabelecimento.Alimento.Designacao; vh.Rating.Rating = alimentoEstabelecimento.Alimento.ClassificacaoMedia; vh.RestaurantName.Text = alimentoEstabelecimento.Estabelecimento.Nome; vh.Distance.Text = string.Format("{0:F2} Km", alimentoEstabelecimento.Distancia / 1000.0f); vh.Street.Text = alimentoEstabelecimento.Estabelecimento.Morada; vh.Contact.Text = alimentoEstabelecimento.Estabelecimento.ContactoTel; }
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { // instantiates the item layout file and the view holder View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.AlimentoCardView, parent, false); ResultadoViewHolder vh = new ResultadoViewHolder(itemView, OnClick); return(vh); }