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

╄→尐↘猪︶ㄣ 提交于 2019-12-06 05:49:16

getItemIndicesInView():Vector.<int> Return the indices of the item renderers visible within this DataGroup.

Manu

I have solved my problem this way:

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>
Dragos

((list.dataGroup.layout) as VerticalLayout).rowCount might be just what you're looking for.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!