2013-04-16 60 views
0

我想在我的Flex移动项目中添加一个图标到视图列表。我不知道如何解决这个问题。这是代码行,下面是视图的图像。如何将图标添加到Adobe Flex移动项目中的视图列表

 <s:List id="calcList" width="100%" height="98%" alternatingItemColors="[#0099999,#990000]" 
      change="calcList_changeHandler(event)" color="#FFFAF0" contentBackgroundColor="#fffdd0" 
      fontWeight="normal" labelField="name" textAlign="left" > 


     <s:dataProvider> 

      <s:ArrayCollection id="calcListCollection"> 
       <fx:Object viewID="A1c" name="A1c " category="Medical"/> 
       <fx:Object viewID="BMI" name="BMI " category="Fitness"/> 
       <fx:Object viewID="GPA" name="GPA " category="Education"/> 
       <fx:Object viewID="Tip" name="Tip " category="Personal" /> 


      </s:ArrayCollection> 
     </s:dataProvider> 
    </s:List> 

enter image description here

+0

使用自定义itemRenderer。 Adobe在移动SDK中包含一个:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/IconItemRenderer.html,您应该可以使用它来达到您的目的。 – JeffryHouser

+0

谢谢,我会给这个镜头。 –

+0

此解决方案完美无瑕,但我相信我没有在需要的部分添加其他部分。根据计算器的选择,我需要图标有所不同。例如,A1c图标将与GPA,TIP和BMI图标不同。 –

回答

0

通过调用项目渲染 “MyIconRenderer” 如下创建了一个名为MyIconRenderer.mxml

一个的.mxml组件
<!--?xml version="1.0" encoding="utf-8"?--> 
    <s:IconItemRenderer 
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    iconField="icon" 
    labelField="name" 
    messageField="category" 
    iconWidth="45" 
    iconHeight="45" 
/> 

然后实现数组列表中的代码:

itemRenderer="MyIconRenderer" 

然后将图标属性传递给您选择的列表'数组集合。

相关问题