Android:SeekBar 增量值 - 如何

发布于 2024-09-12 17:24:31 字数 383 浏览 3 评论 0原文

我的 SeekBar (滑块)工作得很好,但是,当我滑动手指时,它会递增/递减,但是,我想将增量值更改为常量,例如 5。我尝试使用

slider.incrementProgressBy(5);

这样做,但是它不起作用(注意:我将它放置在不同的位置,动作监听器的内部和外部,但它不起作用)。

以下是与此相关的两行:

slider.incrementProgressBy(5);
validBpm = slider.getProgress();

这些行当前位于 SeekBar 的触摸侦听器内。

我认为这很简单,但我忽略了显而易见的事情 - 有什么建议吗?谢谢...

My SeekBar (slider) works just fine but, it increments/decrements by one's as I slide my finger but, I want to change the increment value to a constant, such as 5. I tried using

slider.incrementProgressBy(5);

to do it but, it doesn't work (note: I placed it in different locations, inside and outside the action listener, but it didn't work).

Here are the two lines that relate to this:

slider.incrementProgressBy(5);
validBpm = slider.getProgress();

Those lines are currently inside the SeekBar's touch listener.

I imagine it's simple and I'm overlooking the obvious - any suggestions? Thanks...

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

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

发布评论

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

评论(1

旧夏天 2024-09-19 17:24:31

AFAIK,您无法更改 SeekBar 增量值。相反,更改您的最大值 (setMax()) 并使用乘法。例如,不要使用 0 到 25 递增 5,而是使用 0 到 5 递增 1,然后将 SeekBar 值乘以 5 以获得结果。

AFAIK, you cannot change the SeekBar increment value. Instead, change your max (setMax()) and use multiplication. For example, rather than 0 to 25 incrementing by 5, use 0 to 5 incrementing by one, then multiply the SeekBar value by 5 to get your result.

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