You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用domino-ui创建支持无限点击的HSpinSelect组件

Domino-UI HSpinSelect 实现无限递增模式

Domino-UI 的 HSpinSelect 本身没有内置的无限模式,但可以通过自定义按钮点击逻辑来实现无上限的Long值递增效果:

  • 核心思路:不依赖预设选项集合,手动维护当前值,每次点击「下一个」按钮时直接将当前值加1
  • 代码实现示例:
HSpinSelect<Long> spRepeat = HSpinSelect.create();
// 初始化初始值
spRepeat.setValue(0L);

// 覆盖下一个按钮的点击事件
spRepeat.getNextButton().addClickListener(event -> {
    Long current = spRepeat.getValue();
    spRepeat.setValue(current == null ? 1L : current + 1);
});

// 可选:如果不需要「上一个」功能,可隐藏或禁用按钮
// spRepeat.getPreviousButton().setEnabled(false);
// spRepeat.getPreviousButton().setVisible(false);

通过这种方式,用户每次点击「下一个」按钮都会得到一个全新的递增Long值,没有上限限制。

内容的提问来源于stack exchange,提问作者user438431

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 18:59:55