Alternating row colors in a Flex List control

by Peter deHaan on August 17, 2007

in List

The following example shows how you can alternate row colors in a List control using the alternatingItemColors style.

Full code after the jump

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/08/17/alternating-row-colors-in-a-flex-list-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:ArrayCollection id="arrColl">
        <mx:source>
            <mx:Array>
                <mx:Object label="Row 1" />
                <mx:Object label="Row 2" />
                <mx:Object label="Row 3" />
                <mx:Object label="Row 4" />
                <mx:Object label="Row 5" />
                <mx:Object label="Row 6" />
                <mx:Object label="Row 7" />
                <mx:Object label="Row 8" />
            </mx:Array>
        </mx:source>
    </mx:ArrayCollection>

    <mx:List id="list"
            alternatingItemColors="[0xEEEEEE, 0xDFDFDF]"
            dataProvider="{arrColl}"
            rowCount="4"
            width="200" />

</mx:Application>

View source is enabled in the following example.

{ 2 comments… read them below or add one }

1 sharat87 August 27, 2009 at 4:36 am

Hello, sory to comment on such an old post, but I just wanted to know if it possible to alternate the background alphas of the items in the list in a similar manner?

Great Example, really saved a lot of time :)
sharat87

Reply

2 mohammed September 24, 2009 at 11:47 am

yeh its simple…

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: