Exemplo n.º 1
0
    public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
    {
        // Inflate the CardView for the photo:
        View itemView = LayoutInflater.From(parent.Context).
                        Inflate(Resource.Layout.DealView, parent, false);

        // Create a ViewHolder to find and hold these view references, and
        // register OnClick with the view holder:
        DealAdapterViewHolder vh = new DealAdapterViewHolder(itemView, OnClick);

        return(vh);
    }
Exemplo n.º 2
0
    OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
    {
        DealAdapterViewHolder vh  = holder as DealAdapterViewHolder;
        Resources             res = Android.App.Application.Context.Resources;
        // Set the ImageView and TextView in this ViewHolder's CardView
        // from this position in the photo album:
        int id = (int)typeof(Resource.Drawable).GetField(ViewModelLocator.dealViewModel.Deals[position].ImageUrl).GetValue(null);
        // Converting Drawable Resource to Bitmap
        var myImage = BitmapFactory.DecodeResource(res, id);

        vh.Image.SetImageBitmap(myImage);
        vh.Caption.Text         = ViewModelLocator.dealViewModel.Deals[position].Caption;
        vh.Image.TransitionName = ViewModelLocator.dealViewModel.Deals[position].ImageUrl;
    }