コード例 #1
0
ファイル: GridViewDemoScript2.cs プロジェクト: zqbb/MxDebug
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }