使用列表中的 itemRenderers 显示替代行颜色
我有一个 List
和一个 itemRenderer
用于显示一些数据。无论如何,我可以为交替行设置不同的样式或背景颜色吗?
我的列表
如下:
<mx:List id="myList" alternatingItemColors="[0xffffff, 0xe4e4e4]"
borderStyle="none"
width="100%" height="100%" y="25"
dataProvider="{infoColl}"
styleName="listRendererStyle"
itemRenderer="InfoRenderer"/>
I have a List
with an itemRenderer
for displaying some data. Is there anyway i can set different styles or background colors for alternate rows?
My List
is as follows :
<mx:List id="myList" alternatingItemColors="[0xffffff, 0xe4e4e4]"
borderStyle="none"
width="100%" height="100%" y="25"
dataProvider="{infoColl}"
styleName="listRendererStyle"
itemRenderer="InfoRenderer"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
spark.skins.spark.DefaultItemRenderer
的代码视为模式。有以下代码可获取背景颜色(请参阅updateDisplayList
):但如果您使用
spark.components.supportClasses.ItemRenderer
作为 MXML 渲染器的基类只需将autoDrawBackground
属性设置为true
,所有背景都会自动绘制。或者阅读以下文档如何设置列表的
alternatingItemColors
样式以更改交替行的值。Look at the code of
spark.skins.spark.DefaultItemRenderer
as a pattern. There is the following code to get background color (see inupdateDisplayList
):But if you're using
spark.components.supportClasses.ItemRenderer
as a base class for your MXML renderer just setautoDrawBackground
property totrue
and all the backgrounds will be drawn automatically.Or read the following documentation how to set
alternatingItemColors
style of the list to change the values of alternating rows.对于 Flex3 或 MX,您可以使用
alternatingItemColors
样式属性来实现此目的。对于 Flex4 或 Spark,您可以查看 @Constantiner 的答案以进行精细/深层定制。
猜测
alternatingItemColors
就可以了,并确保您没有将List
的backgroundAlpha
属性设置为 0 或更低的值。For Flex3 or MX, you can use the
alternatingItemColors
style property to achieve this.For Flex4 or Spark, you can look at @Constantiner's answer for a refined / deep level customization.
Guess the
alternatingItemColors
will do, and make sure you haven't turned thebackgroundAlpha
property of theList
to 0 or a lesser value.