Flex4 spark list里面显示序号

Displaying the row number or index in a spark List
[url]http://flexponential.com/2010/02/08/displaying-the-row-number-or-index-in-a-spark-list/[/url]
[img]http://dl.iteye.com/upload/attachment/206948/30c22f1d-5601-38fe-aa1f-5cdea7aa49fd.jpg[/img]

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值