Android 搜索栏如何阻止拖动/短时间禁用它
如果值为 true,我想阻止拖动搜索栏。这可能吗?我使用搜索栏作为开关。如果我的seekbar值为0,并且我按下按钮动作A开始。如果我的搜索栏值为 1 并且按下按钮,操作 B 就会启动。
我想防止如果操作 A 或 B 正在运行,则搜索栏被拖动到另一个位置。
我怎样才能实现这个目标?
I want to block the dragging of a seekbar if a value is true. Is this even possible? I use a seekbar as a switch. If my seekbar value is 0, and I press the button action A started. If my seekbar value is 1 and I press the button action B is started.
I want to prevent that If action A or B is running the seekbar is dragged to another position.
How can I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该设置自己的 onTouchListener 并返回 true。
You should set your own onTouchListener and just return true.
您是否尝试过禁用视图?
参考:
http://developer.android.com/reference/android /view/View.html#setEnabled(boolean)
更新:
https://stackoverflow.com/a/3278616/529691
理想情况下你不应该这样做 ,因为这会让用户感到困惑。我的建议是重新考虑你的方法。
Have you tried disabling the view?
Ref:
http://developer.android.com/reference/android/view/View.html#setEnabled(boolean)
Update:
https://stackoverflow.com/a/3278616/529691
Ideally you shouldn't be doing this, as this is going to confuse the user. My suggestion is rethink your approach.
设置一个类级别变量
根据您的要求
,然后设置
blockSeekBar
变量并在应用程序中使用。 setEnabled(true/false) 也可以选择,但有视图显示效果不佳,这就是为什么上面的代码可以完美工作的原因。Set one class level variable
after that set
blockSeekBar
variable as per your requirement and use in app.setEnabled(true/false) also choice but there view is not showing good so thats why above code is perfectly working.
当 Seekbar.OnSeekbarChangeListener 被触发时,跟踪最后的进度。
Keep track of the last progress when the Seekbar.OnSeekbarChangeListener is fired.