LoopListViewItem2 InitScrollView(LoopListView2 listView, int index) { if (index < 0 || index >= TotalItemCount) { return(null); } CardData itemData = GetItemDataByIndex(index); 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 LoopListView2 Inspector Setting LoopListViewItem2 item = listView.NewListViewItem("CardItem"); CardItem itemScript = item.GetComponent <CardItem>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; itemScript.Init(); } itemScript.SetItemData(itemData, index, true); return(item); }
private LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index) { LoopListViewItem2 item = listView.NewListViewItem("ItemPrefab1"); Item itemScript = item.GetComponent <Item>(); itemScript.SetItemData(index); return(item); }
private void OnMaxLevelChanged(LoopListView2 listView, LoopListViewItem2 item) { int index = listView.GetIndexInShownItemList(item); if (index < 0) { return; } LevelLimitItem itemScript = item.GetComponent <LevelLimitItem>(); m_LevelMax = itemScript.Level; }
private LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index) { LoopListViewItem2 item = listView.NewListViewItem("Image"); ImageBase itemScript = item.GetComponent <ImageBase>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; itemScript.Init(); // 初始化 itemScript,不改变的数据 } int sss = Random.Range(0, 2); itemScript.SetImage(item, Sprite[sss], simulateDate); // 需修改的数据 return(item); }
private LoopListViewItem2 OnGetItemByIndex(LoopViewBase listView, int rowIndex) { if (rowIndex < 0) { return(null); } //create one row LoopListViewItem2 item = listView.NewListViewItem("ItemPrefab"); ItemRow itemScript = item.GetComponent <ItemRow>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; } itemScript.Init(rowIndex, dataCenter); return(item); }
LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index) { if (index < 0) { return(null); } LoopListViewItem2 item = listView.NewListViewItem(poolName); LoopScrollRect2LoopListView2Item itemScript = item.GetComponent <LoopScrollRect2LoopListView2Item>(); itemScript.ScrollCellIndex(index); if (scrollRectIndexCallBack != null) { scrollRectIndexCallBack(index); } return(item); }
private LoopListViewItem2 OnGetItemByIndex(LoopViewBase listView, int index) { if (index < 0 || index >= dataCenter.Count) { return(null); } if (dataCenter[index] == null) { return(null); } LoopListViewItem2 item = listView.NewListViewItem("ItemPrefab"); UI_item compoment = item.GetComponent <UI_item>(); if (!item.IsInitHandlerCalled) { item.IsInitHandlerCalled = true; } compoment.Init(dataCenter[index]); return(item); }
private LoopListViewItem2 OnGetItemByIndex1(LoopListView2 listView, int index) { if (index < 0) { return(null); } /*to check the index'th item is a TreeItem or a TreeChildItem.for example, * * 0 TreeItem0 * 1 TreeChildItem0_0 * 2 TreeChildItem0_1 * 3 TreeChildItem0_2 * 4 TreeChildItem0_3 * 5 TreeItem1 * 6 TreeChildItem1_0 * 7 TreeChildItem1_1 * 8 TreeChildItem1_2 * 9 TreeItem2 * 10 TreeChildItem2_0 * 11 TreeChildItem2_1 * 12 TreeChildItem2_2 * * the first column value is the param 'index', for example, if index is 1, * then we should return TreeChildItem0_0 to SuperScrollView, and if index is 5, * then we should return TreeItem1 to SuperScrollView */ TreeViewItemCountData countData = TreeItemCountMgr.QueryTreeItemByTotalIndex(index); if (countData == null) { return(null); } int treeItemIndex = countData.mTreeItemIndex; TreeItemData treeViewItemData = TreeData.GetItemDataByIndex(treeItemIndex); if (countData.IsChild(index) == false)// if is a TreeItem { //get a new TreeItem LoopListViewItem2 item = listView.NewListViewItem(ItemNameList[0]); TreeItem1 itemScript = item.GetComponent <TreeItem1>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; itemScript.Init(); itemScript.SetClickCallBack(this.OnExpandClicked); } //update the TreeItem's content itemScript.mText.text = treeViewItemData.mName; itemScript.SetItemData(treeItemIndex, countData.mIsExpand); return(item); } else { int childIndex = countData.GetChildIndex(index); GridItemData itemData = treeViewItemData.GetChild(childIndex); if (itemData == null) { return(null); } LoopListViewItem2 item = listView.NewListViewItem(ItemNameList[1]); TreeItem2 itemScript = item.GetComponent <TreeItem2>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; itemScript.Init(); } return(item); } }
public override LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index) { if (index < 0) { return null; } /*to check the index'th item is a TreeItem or a TreeChildItem.for example, 0 TreeItem0 1 TreeChildItem0_0 2 TreeChildItem0_1 3 TreeChildItem0_2 4 TreeChildItem0_3 5 TreeItem1 6 TreeChildItem1_0 7 TreeChildItem1_1 8 TreeChildItem1_2 9 TreeItem2 10 TreeChildItem2_0 11 TreeChildItem2_1 12 TreeChildItem2_2 the first column value is the param 'index', for example, if index is 1, then we should return TreeChildItem0_0 to SuperScrollView, and if index is 5, then we should return TreeItem1 to SuperScrollView */ TreeViewItemCountData countData = TreeItemCountMgr.QueryTreeItemByTotalIndex(index); if (countData == null) { return null; } int treeItemIndex = countData.mTreeItemIndex; TreeItemData treeViewItemData = TreeData.GetItemDataByIndex(treeItemIndex); if (countData.IsChild(index) == false)// if is a TreeItem { //get a new TreeItem LoopListViewItem2 item = listView.NewListViewItem(ItemNameList[0]); TreeItem1 itemScript = item.GetComponent<TreeItem1>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; itemScript.Init(); itemScript.SetClickCallBack(this.OnExpandClicked); } itemScript.mText.text = treeViewItemData.mName; //Debug.Log(index); itemScript.mText.text = m_Achievement1List[treeItemIndex]; itemScript.SetItemData(treeItemIndex, countData.mIsExpand); return item; } else { int childIndex = countData.GetChildIndex(index); GridItemData itemData = treeViewItemData.GetChild(childIndex); if (itemData == null) { return null; } LoopListViewItem2 item = listView.NewListViewItem(ItemNameList[1]); TreeItem2 itemScript = item.GetComponent<TreeItem2>(); if (item.IsInitHandlerCalled == false) { item.IsInitHandlerCalled = true; itemScript.Init(); } itemScript.BtnGet.onClick.AddListener(delegate { Debug.Log("领取 "+itemScript.mNameText.text); }); Vector3 v3 = itemScript.transform.localPosition; itemScript.transform.localPosition = new Vector3(v3.x + 50, v3.y, v3.z); itemScript.SetData(m_Achievement2List[treeItemIndex][childIndex]); return item; } }