public override void OnBindSectionViewHolder(RecyclerView.ViewHolder holder, int sectionIndex) { var viewHolder = (holder as SectionViewHolder); HenspeSectionModel henspeSectionModel = this.itemList.ElementAt(sectionIndex).Key; // Description if (viewHolder.description != null) { viewHolder.description.SetText(henspeSectionModel.description, TextView.BufferType.Normal); } // Header if (viewHolder.header != null) { viewHolder.header.Text = viewHolder.description.Text[0].ToString(); } Color t; if (IsOdd(sectionIndex)) { t = new Color(ContextCompat.GetColor(activity, Resource.Color.evenrow)); } else { t = new Color(ContextCompat.GetColor(activity, Resource.Color.oddrow)); } viewHolder.layout.SetBackgroundColor(t); }
private Dictionary <HenspeSectionModel, List <HenspeRowModel> > PopulateList() { Dictionary <HenspeSectionModel, List <HenspeRowModel> > result = new Dictionary <HenspeSectionModel, List <HenspeRowModel> >(); HenspeSectionModel key = null; foreach (StructureSectionDto structureSectionDto in Henspe.Current.structure.structureSectionList) { key = new HenspeSectionModel(structureSectionDto.image, structureSectionDto.description); foreach (StructureElementDto structureElementDto in structureSectionDto.structureElementList) { HenspeRowModel henspeRowModel = new HenspeRowModel(structureElementDto.elementType, structureElementDto.description, structureElementDto.image); if (result.ContainsKey(key)) { result[key].Add(henspeRowModel); } else { List <HenspeRowModel> HenspeRowList = new List <HenspeRowModel>(); HenspeRowList.Add(henspeRowModel); result.Add(key, HenspeRowList); } } } return(result); }