2012-07-21 18 views

回答

2

這是從s:ListcontentBackgroundColor樣式屬性定義爲改變列表組件的backgroundColor改變列表組件的背景色。

list

MXML例如:

從MXML,設置s:List組件的contentBackgroundColor屬性。

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx"> 

    <s:List contentBackgroundColor="0xabcdef"> 
     <s:dataProvider> 
      <s:ArrayList> 
       <fx:String>Item 1</fx:String> 
       <fx:String>Item 2</fx:String> 
       <fx:String>Item 3</fx:String> 
      </s:ArrayList> 
     </s:dataProvider> 
    </s:List> 

</s:Application> 

的ActionScript示例:

利用ActionScript,設置樣式屬性:setStyle("contentBackgroundColor", 0xabcdef);

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       creationComplete="creationCompleteHandler(event)"> 

    <fx:Script> 
     <![CDATA[ 
      import mx.events.FlexEvent; 

      protected function creationCompleteHandler(event:FlexEvent):void 
      { 
       list.setStyle("contentBackgroundColor", 0xabcdef); 
      } 
     ]]> 
    </fx:Script> 

    <s:List id="list"> 
     <s:dataProvider> 
      <s:ArrayList> 
       <fx:String>Item 1</fx:String> 
       <fx:String>Item 2</fx:String> 
       <fx:String>Item 3</fx:String> 
      </s:ArrayList> 
     </s:dataProvider> 
    </s:List> 

</s:Application> 

這也可以通過爲列表創建一個皮膚類來完成。

相關問題