Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个基于 dataProvider 的火花列表。随着应用程序的运行,dataprovider 中的数据会发生变化,dataProvider 也可以换成不同的
我需要做的是确保总是在列表中选择某些东西(除非它是空的)
您只需requireSelection将列表实例的属性设置为true.
requireSelection
true
在 MXML 中,它将是:
<s:List id="myList" requireSelection="true">
在设置它的数据提供者(或每当改变)之后,你可以做一个:
myList.selectedIndex = 0;
,所以只要是列表中的数据,它的第一项就会被选中(它可以是任何索引,只要记住它从 0 开始到长度 - 1)。