Example #1
0
        LoopGridViewItem OnGetItemByRowColumn(LoopGridView gridView, int itemIndex, int row, int column)
        {
            //get the data to showing
            ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(itemIndex);

            if (itemData == null)
            {
                return(null);
            }

            /*
             * get a new item. Every item can use a different prefab,
             * the parameter of the NewListViewItem is the prefab’name.
             * And all the prefabs should be listed in ItemPrefabList in LoopGridView Inspector Setting
             */
            LoopGridViewItem item = gridView.NewListViewItem("ItemPrefab0");

            ListItem18 itemScript = item.GetComponent <ListItem18>();//get your own component

            // IsInitHandlerCalled is false means this item is new created but not fetched from pool.
            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();// here to init the item, such as add button click event listener.
            }
            //update the item’s content for showing, such as image,text.
            itemScript.SetItemData(itemData, itemIndex, row, column);
            return(item);
        }
        LoopGridViewItem OnGetItemByRowColumn(LoopGridView gridView, int itemIndex, int row, int column)
        {
            ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(itemIndex);

            if (itemData == null)
            {
                return(null);
            }
            LoopGridViewItem item       = gridView.NewListViewItem("ItemPrefab0");
            ListItem19       itemScript = item.GetComponent <ListItem19>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            itemScript.SetItemData(itemData, itemIndex, row, column);
            return(item);
        }
        private LoopGridViewItem OnGetItemByRowColumn(
            LoopGridView gridView,
            int itemIndex,
            int row,
            int column)
        {
            ItemData itemDataByIndex = DataSourceMgr.Get.GetItemDataByIndex(itemIndex);

            if (itemDataByIndex == null)
            {
                return((LoopGridViewItem)null);
            }
            LoopGridViewItem loopGridViewItem = gridView.NewListViewItem("ItemPrefab0");
            ListItem18       component        = (ListItem18)((Component)loopGridViewItem).GetComponent <ListItem18>();

            if (!loopGridViewItem.IsInitHandlerCalled)
            {
                loopGridViewItem.IsInitHandlerCalled = true;
                component.Init();
            }
            component.SetItemData(itemDataByIndex, itemIndex, row, column);
            return(loopGridViewItem);
        }