アクションスクリプトを使用してリストコンポーネントの背景色を変更する方法
1953 次
1 に答える
2
これは、 のcontentBackgroundColor
スタイル プロパティから定義されs:List
ます。
MXML の例:
MXML から、コンポーネントのcontentBackgroundColor
プロパティを設定します。s:List
<?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>
これは、リストのスキン クラスを作成することによっても実現できます。
于 2012-07-21T06:39:47.793 に答える