Android SeekBar setOnSeekBarChangeListener
我想知道 android SeekBars OnSeekBarChangeListener 的行为。特别是, onProgressChanged 方法是否仅在第一次和最后一次触摸搜索栏时收到通知?
我正在尝试刷新应该显示 SeekBar 当前进度的 TextView。但 TextView 只是在第一次触摸和最后一次触摸时更新。对此进行调试证实了我的假设,即该方法仅被调用两次:(我想要的是 TextView 显示 SeekBar 中的每个进度更改。
简而言之:我正在寻找一种获得调用的进度侦听器的可能性每一个微小的进步都会改变。
I'm wondering about the behavior of the android SeekBars OnSeekBarChangeListener. In particular, is the onProgressChanged-method notified only for the first and the last touch on the seekbar?
I'm trying to refresh a TextView that should show the current progress of the SeekBar. But the TextView is just updated on first touch and last touch. Debugging this confirms my assumption that this method is called just twice :( What I would like to have is that the TextView shows every progress change in the SeekBar.
In short: I am searching for a possibility to get a progress listener that is called for every little progress change.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我希望这会对您有所帮助:
I hope this will help you:
onProgressChanged() 应该在每次进度更改时调用,而不仅仅是在第一次和最后一次触摸时调用(这就是为什么你有 onStartTrackingTouch() 和 onStopTrackingTouch() 方法)。
确保你的SeekBar有大于1的值,也就是说你的MAX>=3。
在您的 onCreate 中:
您的侦听器:
请分享一些代码和日志结果以获得进一步的帮助。
onProgressChanged() should be called on every progress changed, not just on first and last touch (that why you have onStartTrackingTouch() and onStopTrackingTouch() methods).
Make sure that your SeekBar have more than 1 value, that is to say your MAX>=3.
In your onCreate:
Your listener:
Please share some code and the Log results for furter help.
每次移动光标时都会调用 onProgressChanged。
因此,textView 应该显示进度,并在移动搜索栏时始终更改。
onProgressChanged is called every time you move the cursor.
so textView should show the progress and alter always if the seekbar is being moved.
所有答案都是正确的,但是您需要首先将一个又长又大的数字转换为计时器:
这就是您使用它的方式:
All answers are correct, but you need to convert a long big fat number into a timer first:
And this is how you use it:
覆盖所有方法
Override all methods
当我们第一次初始化时,Seekbar 调用了 onProgressChanged 方法。我们可以使用下面的代码跳过
我们需要检查 boolean 它在自动初始化时返回 false
Seekbar called onProgressChanged method when we initialize first time. We can skip by using below code
We need to check boolean it return false when initialize automatically