开发者

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 L开发者_高级运维ist was scrolled/the visible items changed?

Thank you,

João Saleiro


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


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>


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜