How to get the visible items on a Spark List with virtual layout

I have:

  • an ArrayCollection of Numbers;
  • a List using the above ArrayCollection as it's dataprovider, and virtualLayout=true;
  • a custom ItemRenderer that shows a label with: a) the number b) an y position depending on the number AND the highest number visible
  • In another words, if I have 10 numbers in the AC, and only 5 appear on the screen, the y position of those 5 will depend on the value of the maximum number for those 5. When the user scrolls, of course those 5 elements change so the position of the label in item renderers will change.

    My questions:

    1) How can I get the list of items that are "currently" visible? 2) Which event/method to override will help me know that the List was scrolled/the visible items changed?

    Thank you,

    João Saleiro


    getItemIndicesInView():Vector.<int>返回此DataGroup中可见的项呈示器的索引。


    我用这种方式解决了我的问题:

    protected function pagedList_touchInteractionEndHandler(event:TouchInteractionEvent):void
    {
        var _index:int = (event.currentTarget.scroller.viewport.layout.horizontalScrollPosition / event.currentTarget.scroller.viewport.layout.columnWidth);                
    }
    
    <s:List id="pagedList" scrollSnappingMode="center" selectionColor="#FFFFFF" downColor="#FFFFFF" focusAlpha="0" 
                width="100%" height="100%" useVirtualLayout="true"
                verticalScrollPolicy="off" horizontalScrollPolicy="on"
                pageScrollingEnabled="true" 
                itemRenderer="myItemRender" 
                skinClass="skins.PagedListSkin" 
                touchInteractionStart="pagedList_touchInteractionStartHandler(event)" touchInteractionEnd="pagedList_touchInteractionEndHandler(event)" >
            <s:layout>
                <s:TileLayout orientation="rows" requestedRowCount="1" 
                    columnWidth="{pagedList.width}" rowHeight="{pagedList.height}" 
                    verticalGap="0" horizontalGap="0" />
            </s:layout>
    </s:List>
    

    ((list.dataGroup.layout) as VerticalLayout).rowCount可能正是你正在寻找的。

    链接地址: http://www.djcxy.com/p/34640.html

    上一篇: 列表中的复选框图像

    下一篇: 如何使用虚拟布局获取Spark List上的可见项目