OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { TaskViewHolder vh = holder as TaskViewHolder; // Set the ImageView and TextView in this ViewHolder's CardView // from this position in the photo album: vh.Title.Text = _tasks[position].Title; vh.Start.Text = _tasks[position].Start == DateTime.MinValue ? "N/A" : _tasks[position].Start.ToLongDateString(); vh.Repeat.Text = _tasks[position].Repeat.ToString(); var drawable = vh.Importance.Drawable; Color color = default; switch (_tasks[position].Importance) { case Importance.Low: color = Color.Green; break; case Importance.Medium: color = Color.Yellow; break; case Importance.High: color = Color.Red; break; } drawable.SetColorFilter(color, PorterDuff.Mode.Src); }
OnCreateViewHolder(ViewGroup parent, int viewType) { // Inflate the CardView for the photo: View itemView = LayoutInflater.From(parent.Context). Inflate(Resource.Layout.item_task_recycler_view, parent, false); // Create a ViewHolder to find and hold these view references, and // register OnClick with the view holder: TaskViewHolder vh = new TaskViewHolder(itemView, OnClick, OnDeleteClick); return(vh); }