Пример #1
0
        // Create a new views / photo CardView (invoked by the layout manager):
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            //Setup your layout here
            // Inflate the CardView for the photo:
            View itemView = LayoutInflater.From(parent.Context).
                            Inflate(Resource.Layout.NewsObject_CardView, parent, false);

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

            return(vh);
        }
Пример #2
0
        // Fill in the contents of a view / the photo card (invoked by the layout manager):
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            // Replace the contents of the view with that element
            NewsObject_RecycleAdapter_NEW_ViewHolder vh = viewHolder as NewsObject_RecycleAdapter_NEW_ViewHolder;

            // Set the ImageView and TextView in this ViewHolder's CardView
            // from this position in the List<newsObject>

            //  Assign content (get currency icon 1st)
            string countryChar = mNewsObjectList[position].CountryChar.ToString().ToUpper();
            int    imageID     = GetImageForCurrency(countryChar);

            vh.Icon.SetImageResource(imageID);

            //  Assign content - continued
            vh.Caption1.Text = mNewsObjectList[position].CountryChar + ": " + mNewsObjectList[position].MarketImpact;
            vh.Caption2.Text = mNewsObjectList[position].DateAndTime.ToString("dd/MM/yyyy") + ":  "
                               + mNewsObjectList[position].DateAndTime.ToString("HH:mmtt") + "\n"
                               + mNewsObjectList[position].Title;
        }