如何确保 Spark 列表中始终有某些内容被选中?

发布于 2024-08-30 18:10:11 字数 118 浏览 3 评论 0原文

我有一个基于 dataProvider 的 Spark 列表。当应用程序运行时,数据提供者中的数据可能会发生变化,并且数据提供者也可以交换为不同的数据

我需要做的是确保列表中始终选择某些内容(除非它是空的)

I have a spark list, which is based on a dataProvider. As the application runs, the data in the dataprovider can change, and also the dataProvider can be swapped for a different one

What I need to do is make sure that something is always selected in the list (unless it is empty)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ι不睡觉的鱼゛ 2024-09-06 18:10:11

您只需将列表实例的属性 requireSelection 设置为 true 即可。

在 MXML 中,它将是:

<s:List id="myList" requireSelection="true">

You simply have to set the property requireSelection of your list instance to true.

In MXML, it would be:

<s:List id="myList" requireSelection="true">
一桥轻雨一伞开 2024-09-06 18:10:11

设置其数据提供者后(或每当更改时),您可以执行 a:

myList.selectedIndex = 0;

,因此每当列表中的数据时,都会选择其第一项(可以是任何索引,只需记住它从 0 开始到长度 - 1 )。

After setting its data provider ( or whenever is changed ) you could do a:

myList.selectedIndex = 0;

, so whenever the is data on your list, its first item will be selected (it could be any index, just remember that it start from 0 to length - 1).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文