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; } }