We can say item renderer as custom component, which we can define by our own. We can set it properties , can add image , text, label and all that can be done dynamic too.
Let say we can have a list and its dataprovider will be array collection , its itemRenderer will be our custom item renderer and will be behaving according to our properties.
Eg. Lets consider we have a array collection (_arrayColl) with five elements which contains objects having a label and an icon image.
Each object have properties like : - obj.name = “My computer”; obj.icon =”myComp.png”;
Lets define ItemRenderer first : – listRenderer.mxml
<?xml version=”1.0″ encoding=”utf-8″?>
<s:ItemRenderer xmlns:fx=”http://ns.adobe.com/mxml/2009″ xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:views=”views.*” width=”295″ height=”44″ >
<s:Label id=”name” x=”3″ y=”13″ enabled=”false” fontFamily=”Arial” text=”{data.name}” />
<s:Image x=”237″ y=”13″ source=”{data.icon}” />
</s:ItemRenderer>
Now above mxml can be called inside list as : -
<s:List id=”dlist” x=”12″ y=”171″ width=”295″ height=”216″ dataProvider=”{_arrayColl}”
itemRenderer=”listRenderer” />
Now we are done : You can see your list showing the data correctly with five items.
Feel free to put comments.