使用列表中的 itemRenderers 显示替代行颜色

发布于 2024-11-24 20:26:36 字数 381 浏览 3 评论 0原文

我有一个 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

把时间冻结 2024-12-01 20:26:36

spark.skins.spark.DefaultItemRenderer 的代码视为模式。有以下代码可获取背景颜色(请参阅 updateDisplayList):

        var alternatingColors:Array = getStyle("alternatingItemColors");

        if (alternatingColors && alternatingColors.length > 0)
        {
            // translate these colors into uints
            styleManager.getColorNames(alternatingColors);

            backgroundColor = alternatingColors[itemIndex % alternatingColors.length];
        }

但如果您使用 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 in updateDisplayList):

        var alternatingColors:Array = getStyle("alternatingItemColors");

        if (alternatingColors && alternatingColors.length > 0)
        {
            // translate these colors into uints
            styleManager.getColorNames(alternatingColors);

            backgroundColor = alternatingColors[itemIndex % alternatingColors.length];
        }

But if you're using spark.components.supportClasses.ItemRenderer as a base class for your MXML renderer just set autoDrawBackground property to true 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.

神经暖 2024-12-01 20:26:36

对于 Flex3 或 MX,您可以使用 alternatingItemColors 样式属性来实现此目的。

<mx:List id="myList" alternatingItemColors="[0xffffff, 0xe4e4e4]"/>

对于 Flex4 或 Spark,您可以查看 @Constantiner 的答案以进行精细/深层定制。

猜测 alternatingItemColors 就可以了,并确保您没有将 ListbackgroundAlpha 属性设置为 0 或更低的值。

For Flex3 or MX, you can use the alternatingItemColors style property to achieve this.

<mx:List id="myList" alternatingItemColors="[0xffffff, 0xe4e4e4]"/>

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 the backgroundAlpha property of the List to 0 or a lesser value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文