首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex4 spark list里头显示序号

2012-11-23 
Flex4 spark list里面显示序号Displaying the row number or index in a spark Listhttp://flexponential.

Flex4 spark list里面显示序号
Displaying the row number or index in a spark List
http://flexponential.com/2010/02/08/displaying-the-row-number-or-index-in-a-spark-list/

<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"                xmlns:s="library://ns.adobe.com/flex/spark" width="200" height="215"  viewSourceURL="srcview/index.html">        <s:List height="200" width="200" top="10">        <s:layout>            <s:VerticalLayout gap="1" horizontalAlign="justify" />        </s:layout>        <s:dataProvider>            <s:ArrayList>                <fx:String>Roberto Luongo</fx:String>                <fx:String>Scott Niedermayer</fx:String>                <fx:String>Jarome Iginla</fx:String>                <fx:String>Dan Boyle</fx:String>                <fx:String>Rick Nash</fx:String>                <fx:String>Ryan Getzlaf</fx:String>                <fx:String>Martin Brodeur</fx:String>                <fx:String>Chris Pronger</fx:String>                <fx:String>Shane Doan</fx:String>                <fx:String>Shea Weber</fx:String>                <fx:String>Patrick Marleau</fx:String>                <fx:String>Jay Bouwmeester</fx:String>                <fx:String>Duncan Keith</fx:String>                <fx:String>Dany Heatley</fx:String>                <fx:String>Robyn Regehr</fx:String>                <fx:String>Mike Richards</fx:String>                <fx:String>Brenden Morrow</fx:String>                <fx:String>Martin St. Louis</fx:String>                <fx:String>Jeff Carter</fx:String>                <fx:String>Eric Staal</fx:String>                <fx:String>Sidney Crosby</fx:String>            </s:ArrayList>        </s:dataProvider>        <s:itemRenderer>            <fx:Component>                <s:ItemRenderer>                    <fx:Script>                        <![CDATA[                            import spark.components.List;                            override public function set data(value:Object):void {                                super.data = value;                                                                if (value == null)                                    return;                                                                txtPlayer.text = String(data);                                txtRowNumber.text = String(itemIndex);                                                                // NOTE: In older builds ItemRenderer.itemIndex didn't exist yet.  If you are on an older                                // build you can get this information using the following line instead:                                //                                //txtRowNumber.text = String((owner as List).dataProvider.getItemIndex(data));                            }                        ]]>                    </fx:Script>                    <s:Group>                        <s:Rect width="25" height="20">                            <s:fill>                                <s:SolidColor color="0xFF0000" />                            </s:fill>                        </s:Rect>                        <s:Label id="txtRowNumber" color="white" fontWeight="bold" horizontalCenter="0" verticalCenter="0" />                    </s:Group>                                        <s:Label id="txtPlayer" x="30" verticalCenter="0" />                </s:ItemRenderer>            </fx:Component>        </s:itemRenderer>    </s:List>    </s:Application>

热点排行