Flex列出行的自定义颜色

时间:2012-04-12 02:08:08

标签: actionscript-3 flex

是否可以根据其中的数据为flex列表中的行设置自定义颜色。我知道如何定义自定义itemrenderer并执行此操作,但我想知道是否有任何简单的方法,因为我不知道我想要更多的组件

2 个答案:

答案 0 :(得分:1)

无法在不修改或替换itemRenderer的情况下向itemRenderer添加自定义颜色,以显示您的数据。

Flex中基于列表的类使用itemRenderers来显示数据。如果您创建自己的,则替换默认的itemRenderer。它不会在内存中创建更多组件;它只会改变那些组件。

答案 1 :(得分:0)

你可以创建自己的自定义列表类,并通过覆盖受保护的绘制RowBackground方法....你可能会实现这个....

protected override function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void {
      if (rowColoringFunction != null && IList(dataProvider).length > dataIndex) {
        color = rowColoringFunction(IList(dataProvider).getItemAt(dataIndex), dataIndex, color);
      }
      super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
    }

试着让我知道......