0

リストのカスタム アイテム レンダラーを作成して、複数の StyleTextField を使用して複数のデータ列を作成できるようにしています。

私は MXML と Actionscript の混合物に取り組んでいます (StyleableTextField は Actionscript を介してのみ作成できるため)。

ただし、幅を揃えるのに問題があります。幅を設定するために使用している Actionscript は次のとおりです。

var id:StyleableTextField = StyleableTextField(createInFontContext(StyleableTextField));                
id.width = (itemContainer.width * 30/100);
id.htmlText = "Text Here";

var desc:StyleableTextField = StyleableTextField(createInFontContext(StyleableTextField));              
desc.width = (itemContainer.width * 70/100);
desc.htmlText = "Much longer text description goes here";

ご覧のとおり、コンテナーの幅に基づいて幅を設定しようとしています (以下を参照)。

また、percentWidth と明示的な幅を設定しようとしましたが、列の幅はまだ変化しているようです。

私の MXML は次のようになります。

<s:Group width="100%">
    <s:HGroup id="itemContainer" verticalAlign="middle" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" width="100%" gap="10">
    </s:HGroup>
</s:Group>

特に id 列は、その傾向のある幅よりも大きくなりたくないようです。複数の行にできる desc 列はより適切に機能しますが、すべての行にわたって単一の幅に固執しません。

アップデート:

アレックスが提案したことを試してみると、次の ActionScript コードができました。それはあまりしていないようですが。

override protected function updateDisplayList(unscaledWidth : Number, unscaledHeight : Number) : void {
if (idno == null)
{
idno = createDisplay(data.idno);
}
super.updateDisplayList(unscaledWidth, unscaledHeight);
idno.width = (unscaledWidth * 30/100);
desc.width = (unscaledWidth * 70/100);
trace (idno.width);
trace (desc.width);
}

protected function createDisplay(value:String):StyleableTextField
{
var field:StyleableTextField = StyleableTextField(createInFontContext(StyleableTextField));
field.text = value;
itemContainer.addElement(field);
return field;
}
4

1 に答える 1

0

やってみました:

override protected function updateDisplayList(unscaledWidth : Number, unscaledHeight : Number) : void {
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    id.width = (unscaledWidth * 30/100);
    desc.width = (unscaledWidth * 70/100);
}
于 2012-10-13T12:54:51.660 に答える