2013-04-16 58 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" 

然後將圖標屬性傳遞給您選擇的列表'數組集合。

相關問題