// 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.UserAlert_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 UserAlert_RecycleAdapter_NEW_ViewHolder(itemView, OnClick); // , OnLongClick return(vh); }
// 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 UserAlert_RecycleAdapter_NEW_ViewHolder vh = viewHolder as UserAlert_RecycleAdapter_NEW_ViewHolder; // Set the ImageView and TextView in this ViewHolder's CardView // from this position in the List<newsObject> (photo album) // Assign content (get currency icon 1st) string countryChar = mUserAlertList[position].CountryChar.ToString().ToUpper(); int imageID = GetImageForCurrency(countryChar); vh.Icon.SetImageResource(imageID); // Assign content - continued vh.Caption1.Text = mUserAlertList[position].CountryChar + ": " + mUserAlertList[position].MarketImpact; vh.Caption2.Text = mUserAlertList[position].DateAndTime.ToString("dd/MM/yyyy") + ": " + mUserAlertList[position].DateAndTime.ToString("HH:mmtt") + "\n" + mUserAlertList[position].Title + ":" + "\n\n" + mUserAlertList[position].DescriptionOfPersonalEvent; }