Flex3学习轨迹:为List控件添加图标

List以垂直方式来显示控件。在通常的情况下,List中只显示文本信息。这里将使用内嵌图标的方式来显示带有图标的信息。


Flex3学习轨迹:为List控件添加图标_第1张图片



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" fontSize="12" >
    <mx:Script>
        <![CDATA[
            [Bindable]
            [Embed(source="assets/AA.png")]
            public var AA:Class;
            [Bindable]
            [Embed(source="assets/BB.png")]
            public var BB:Class;
            [Bindable]
            [Embed(source="assets/CC.png")]
            public var CC:Class;
        ]]>
    </mx:Script>
    <mx:Panel title="为List控件项添加图标" width="320" height="200" 
        verticalAlign="middle" horizontalAlign="center">
            <mx:List id="list" labelField="label" iconField="icon" rowCount="5"
                width="260" textIndent="5" allowMultipleSelection="true">
                <mx:dataProvider>
                    <mx:Array>
                        <mx:Object label="Item 1" icon="BB" />
                        <mx:Object label="Item 2" icon="CC" />
                        <mx:Object label="Item 3" icon="CC" />
                        <mx:Object label="Item 4" icon="AA" />
                        <mx:Object label="Item 5" icon="BB" />
                        <mx:Object label="Item 6" icon="AA" />
                        <mx:Object label="Item 7" icon="AA" />
                        <mx:Object label="Item 8" icon="CC" />
                    </mx:Array>
                </mx:dataProvider>
            </mx:List>            
    </mx:Panel>
</mx:Application>


你可能感兴趣的:(object,list,Flex,application,Class,encoding)