开发者

Sizing a spark list

I'm using spark Lists and PopupAnchors to build a drop down menu system, but I'm having trouble getting it to size reliably - the list always seems to want to take up 5 itemRenderers worth of space, but some of the menus I need to implement can be 3 o开发者_如何学Pythonr less items long. How can I have the list dynamically size to the number of elements in it, and no larger?


This is a fun one. You need to set the property on the VerticalLayout of the spark list.

Try this snippet:

(yourSparkList.layout as VerticalLayout).requestedRowCount = yourDataProvider.length;

This assumes you've got a list named yourSparkList and a dataprovider called yourDataProvider which is populating the list.

If your lists get long, you should set a MAXIMUM constant like so:

public static const MAXIMUM:int = 5;

if(yourDataProvider.length <= MAXIMUM){
    (yourSparkList.layout as VerticalLayout).requestedRowCount = yourDataProvider.length;
}else{
    (yourSparkList.layout as VerticalLayout).requestedRowCount = MAXIMUM;
}

BTW, there's also a requestedMaxRowCount and a requestedMinRowCount property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜