2011-08-09 24 views
1

我終於成功地讓我的名單水平渲染,但問題是這樣的:Flex的名單:上述標籤字段的圖標,中心

當我運行的應用程序,我看到名單如下:My list view (iPad)

不介意標籤字段,數據是從測試中收集的XML

問題是,我希望列表顯示標籤字段上方的圖標(標籤'file1'上方的iMac圖像)和兩者以中心爲中心。

這裏是清單代碼在我HomeView:

<s:List id="tripList" left="0" right="0" top="0" bottom="0" 
     change="tripList_changeHandler(event)" dataProvider="{data}" horizontalCenter="0" 
     labelField="title" verticalCenter="0"> 
    <s:layout> 
     <s:TileLayout/> 
    </s:layout> 
    <s:itemRenderer> 
     <fx:Component> 
      <s:IconItemRenderer iconFunction="getPhotoURL" iconWidth="128" iconHeight="128" height="150" width="379" verticalAlign="top" textAlign="center"> 
       <fx:Script> 
        <![CDATA[ 
         protected function getPhotoURL(item:Object):String 
         { 
          return "images/mine/" + item.image 
         } 
        ]]> 
       </fx:Script> 
      </s:IconItemRenderer> 
     </fx:Component> 
    </s:itemRenderer> 
</s:List> 

THX任何答案!

+1

+1了良好的結構問題。要點是創建您自己的自定義itemRenderer以按您想要的方式佈局元素。 – JeffryHouser

回答

2

這樣的事情...

<s:List id="tripList" left="0" right="0" top="0" bottom="0" 
      horizontalCenter="0" 
      labelField="title" verticalCenter="0"> 
     <s:layout> 
      <s:TileLayout/> 
     </s:layout> 
     <s:dataProvider> 
      <s:ArrayList> 
       <fx:Object title="item 1" icon="adobe-logo.jpg" /> 
       <fx:Object title="item 2" icon="adobe-logo.jpg" /> 
       <fx:Object title="item 3" icon="adobe-logo.jpg" /> 
       <fx:Object title="item 4" icon="adobe-logo.jpg" /> 
       <fx:Object title="item 5" icon="adobe-logo.jpg" /> 
       <fx:Object title="item 6" icon="adobe-logo.jpg" /> 
      </s:ArrayList> 
     </s:dataProvider> 
     <s:itemRenderer> 
      <fx:Component> 
       <s:ItemRenderer> 
        <s:VGroup horizontalAlign="center"> 
         <s:Image source="{data.icon}" /> 
         <s:Label text="{data.title}" /> 
        </s:VGroup> 
       </s:ItemRenderer> 
      </fx:Component> 
     </s:itemRenderer> 
    </s:List> 
+0

這個工程,但有一個很大的問題...當我設置ItemRenderer的寬度,例如。到379,就像我在我的例子中那樣,文本/ labieldield正好在圖像下,但圖像不在ItemRenderer(一個對象)圖像的中心:http://www.image-share.com/ upload/841/149.png – Fasand

+1

嘗試''或者更加動態一點'」如果你正在尋找3列 – SuperSaiyen

+0

耶!它的作品,非常感謝!雖然FlexGlobals似乎不工作,但不知道爲什麼,但無所謂......非常感謝! – Fasand