我遇到一个问题,即加载包含100个条目的列表需要很长时间。我使用预生成的arraycollection传递给数据提供程序,自定义项呈示器由嵌套容器组成。我称之为list.dataProvider = arraycollection;
的那一刻,它冻结了大约4秒,然后只显示列表。
是否有解决此问题的解决方法?
以下是我的代码:
[编辑]
private function populateList():void
{
array = new Array();
for (var i:int =0;i<100;i++)
{
array.push({
dateLabel:"LIVE",
timeLabel:"06:05",
homeTeamLabel:"Liverpool",
homeScoreLabel:"1",
awayScoreLabel:"0",
awayTeamLabel:"Chelsea",
homeTeamHandicapLabel:"Liverpool",
homeHandicapLabel:"2/5",
awayTeamHandicapLabel:"Chelsea",
awayHandicapLabel:"",
priceHomeHandicapLabel:"1.950",
priceAwayHandicapLabel:"1.950"
});
}
trace("done loading");
testarr = new ArrayCollection(array);
liveList.dataProvider = testarr;
}
这是我的列表组件:
<s:Scroller width="100%" height="100%" horizontalScrollPolicy="off">
<s:VGroup id="lists" gap="0" left="0" right="0" top="0" bottom="0">
<s:List id="liveList" width="100%" itemRenderer="customItemRenderer" creationComplete="populateList()"
contentBackgroundColor="0xf0f0f0" useVirtualLayout="true" depth="0" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<s:layout>
<s:VerticalLayout gap="0" variableRowHeight="true" requestedMinRowCount="1" useVirtualLayout="true"/>
</s:layout>
</s:List>
</s:VGroup>
</s:Scroller>
答案 0 :(得分:0)
事实证明,当我使用Scroller和VGroup包装列表时,性能会受到影响。当我删除它们时,列表加载就好了。