示例#1
0
        /// <inheritdoc/>
        protected override void UpdateCellViewsHolder(MyCellViewsHolder newOrRecycled)
        {
            // Initialize the views from the associated model
            MyCellModel model = _Data[newOrRecycled.ItemIndex];

            newOrRecycled.UpdateViews(model);
        }
        void CreteRandomItemsForChildScrollView(ChildAdapterViewsHolder viewsHolder, ChildAdapterModel childScrollViewModel, int count)
        {
            int nextFreeId = viewsHolder.childGrid.GetItemsCount();             // the "id" (used only to show it in TitleText) for the first created item is the current items count;
            var list       = new List <MyCellModel>(count);

            for (int i = 0; i < count; i++)
            {
                var cellModel = new MyCellModel()
                {
                    title = nextFreeId + "",
                    color = DemosUtil.GetRandomColor(false)
                };
                ++nextFreeId;
                list.Add(cellModel);
            }

            // The childScrollViewModel keeps track of items, because the
            // child script is not a "persistent storage" - it's being constantly recycled
            childScrollViewModel.items = new List <MyCellModel>(list);
            viewsHolder.childGrid.SetItemsAndUpdate(list);
        }
示例#3
0
 public void UpdateViews(MyCellModel model)
 {
     titleText.text = model.title;
     image.color    = model.color;
 }