0

当我为 dataProvider 提供新值时,我想在列表中选择该新项目,但它选择了首先选择的项目,以及如何在应用程序启动时永久选择该项目。

4

1 回答 1

0

添加到 dataProvider 后,如果要选择列表项。可能你遵循这个

list.selectedIndex = list.dataProvider.length -1;

有时,如果您在所需位置添加,例如

 list.dataProvider.setItemAt(obj,2); 

 list.selectedIndex = 2

如果您想在 App 启动时永久选择项目。(确保您的数组集合可绑定到列表)

    public function onCreationComplete(event:FlexEvent):void
{
    callLater(function():void
    {
        list.selectedIndex = list.dataProvider.length -1;
        list.ensureIndexIsVisible(list.selectedIndex); // Viewport
    });
}
于 2012-10-22T08:07:00.443 回答