private LoopListViewItem2 OnGetItemByIndex( LoopListView2 listView, int rowIndex) { if (rowIndex < 0) { return((LoopListViewItem2)null); } LoopListViewItem2 loopListViewItem2 = listView.NewListViewItem("RowPrefab"); ListItem15 component = (ListItem15)((Component)loopListViewItem2).GetComponent <ListItem15>(); if (!loopListViewItem2.IsInitHandlerCalled) { loopListViewItem2.IsInitHandlerCalled = true; component.Init(); } for (int index = 0; index < 3; ++index) { int num = rowIndex * 3 + index; if (num >= this.mItemTotalCount) { ((Component)component.mItemList[index]).get_gameObject().SetActive(false); } else { ((Component)component.mItemList[index]).get_gameObject().SetActive(true); component.mItemList[index].mNameText.set_text("Item" + (object)num); } } return(loopListViewItem2); }
/*when a row is getting show in the scrollrect viewport, * this method will be called with the row’ index as a parameter, * to let you create the row and update its content. * * SuperScrollView uses single items with subitems that make up the columns in the row. * so in fact, the GridView is ListView. * if one row is make up with 3 subitems, then the GridView looks like: * * row0: subitem0 subitem1 subitem2 * row1: subitem3 subitem4 subitem5 * row2: subitem6 subitem7 subitem8 * row3: subitem9 subitem10 subitem11 * ... */ LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int rowIndex) { if (rowIndex < 0) { return(null); } //create one row LoopListViewItem2 item = listView.NewListViewItem("RowPrefab"); ListItem15 itemScript = item.GetComponent <ListItem15>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; itemScript.Init(); } //update all items in the row for (int i = 0; i < mItemCountPerRow; ++i) { int itemIndex = rowIndex * mItemCountPerRow + i; if (itemIndex >= mItemTotalCount) { itemScript.mItemList[i].gameObject.SetActive(false); continue; } //update the subitem content. itemScript.mItemList[i].gameObject.SetActive(true); itemScript.mItemList[i].mNameText.text = "Item" + itemIndex; } return(item); }