以虚线分隔List项目(drawRowBackground应用一例)

 今天我们将通过继承List组件并重写drawRowBackground函数的方式自定义List的样式..
让List的每个项目以虚线隔开~~

点此显示/隐藏媒体

 

override protected function drawRowBackground(s:Sprite,rowIndex:int,y:Number,height:Number,color:uint,dataIndex:int):void
{
super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);
var bg:Shape = Shape(s.getChildAt(rowIndex));
//此外为了显示虚线~使用一个while来循环来模拟虚线效果~
var p:Number = 0;
bg.graphics.lineStyle(1,0xCCCCCC);
while(p < listContent.width)
{
bg.graphics.moveTo(p,height-1);
bg.graphics.lineTo(p+4,height-1);
p += 6;
}
}


需要注意的一点~

<L4cd:iList alternatingItemColors="0xFFFFFF" rowHeight="25" dataProvider="{list}" 
labelField="label" left="10"
top="10" right="10" bottom="10"/>


要触发drawRowBackground函数~必须先设置alternatingItemColors这个style~因为drawRowBackground的作用是用来画item的背景的,没有设置背景将不会触发drawRowBackground~

源码下载http://l4cd.net/Blog/article.asp?id=85

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值