Home arrow XML arrow Page 4 - Flex List Controls

A Reusable Item Renderer - XML

The List Control is a fundamental control for use in Flex. It can be used in many different situations and can display all types of data. Anything from images to plain text and even basic HTML (supported by Flex) can be used. Keep reading for an introduction to this versatile control.

  1. Flex List Controls
  2. Creating an XML List
  3. Adding an Item Renderer
  4. A Reusable Item Renderer
By: Keith Lee
Rating: starstarstarstarstar / 15
July 07, 2009

print this article



 As stated earlier, here is the same application, but this code uses a reusable itemRenderer:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml 
<mx:Component id="myItemRenderer"> <mx:HBox> <mx:CheckBox/>
<mx:Label text="{data.@label}"/>
</mx:HBox> </mx:Component>
<mx:Panel title="My List" width="100%"> <mx:List labelField="@label" width="100%" itemRenderer="{myItemRenderer}"> <mx:dataProvider> <mx:XMLList xmlns=""> <fruit label="Apple"/> <fruit label="Orange"/> <fruit label="Cherry"/> <fruit label="Mango"/> <fruit label="Peach"/> <fruit label="Plum"/> <fruit label="Banana"/> </mx:XMLList> </mx:dataProvider> </mx:List> </mx:Panel> </mx:Application>

Notice the declaration of the <mx:Component> tag outside of out <mx:List> tag. Now that this definition is not tied to the list control, and other data aware control can use it as an item renderer.

There you have it. A easy introduction into the List Control and Item Renderers. Enjoy.

>>> More XML Articles          >>> More By Keith Lee

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Google Docs and Xpath Data Functions
- Flex Array Collection Sort and Filtering
- The Flex Tree Control
- Flex List Controls
- Working with Flex and Datagrids
- How to Set Up Podcasting and Vodcasting
- Creating an RSS Reader Application
- Building an RSS File
- An Introduction to XUL Part 6
- An Introduction to XUL Part 5
- An Introduction to XUL Part 4
- An Introduction to XUL Part 3
- An Introduction to XUL Part 2
- An Introduction to XUL Part 1
- XML Matters: Practical XML Data Design and M...

Developer Shed Affiliates


Dev Shed Tutorial Topics: