2

xml ファイルから horizo​​ntalList コンポーネントを設定したいのですが、幅の値はすべてのデータとともに xml ファイル内にあります。

実際に私はこのコードを持っています:

<mx:Model id="epg" source="epg.xml" /> 

<mx:Component id="customRend">
    <mx:Label text="{data.description}" width="{data.width}"/> 
</mx:Component>

<mx:HBox x="82" y="104" width="1203" height="113" verticalAlign="middle">
    <mx:HorizontalList width="100%"  dataProvider="{epg.channel.program}" 
        itemRenderer="{customRend}" horizontalScrollPolicy="off">
    </mx:HorizontalList> 
</mx:HBox>

ただし、リスト内のすべての要素に同じ幅を設定します。

これを行う方法を知っていますか?

どうもありがとう。Br

4

1 に答える 1

0

これを行うには 2 つの方法があります。

  • label.width = data.widthオンに設定creationComplete
  • ラベルをキャンバスで包む

creationComplete の方法 (おそらく、itemRenderer がコンテナであるべきなので?):

<mx:HorizontalList width="100%" dataProvider="{epg.channel.program}"  horizontalScrollPolicy="off">
    <mx:itemRenderer>
        <mx:Component id="customRend">
            <mx:Label text="{data.description}" creationComplete="this.width = data.width"/> 
        </mx:Component>
    </mx:itemRenderer>
</mx:HorizontalList>

...またはキャンバスにラップ:

<mx:HorizontalList width="100%" dataProvider="{epg.channel.program}"  horizontalScrollPolicy="off">
    <mx:itemRenderer>
        <mx:Component id="customRend">
            <mx:Canvas horizontalScrollPolicy="off">
                <mx:Label text="{data.description}" width="{data.width}"/> 
            </mx:Canvas>
        </mx:Component>
    </mx:itemRenderer>
</mx:HorizontalList>

お役に立てば幸いです、ランス

于 2010-02-25T11:27:56.577 に答える