问题描述
我使用搜索栏在我的Android应用程序的滑块equalant,因为我无法找到一个滑块控件在Android SDK中..我能输入值,通过搜索栏正确。我的问题是,当用户单一的水龙头上的搜索栏的任意位置其进度值被改变,这是不是我want..I只希望当用户滑动SeekBar的手柄(就像在iPhone上UISlider)的进展。我有搜索栏的点击属性设置为false但没有happening..How我可以禁用progressChange当用户点击搜索栏。
I am using SeekBar as a slider equalant in my android app since I cant find a Slider widget in Android SDK.. I am able to input value through the seekbar correctly.. My problem is when user single tap anywhere on the seekbar its progress value is changed which is not what I want..I only want progress when user slides the handle of the seekbar (just like a UISlider in iphone). I have set the clickable property of the seekbar to false but nothing happening..How can I disable progressChange when user clicks on the seekBar..
推荐答案
我面临着同样的问题,这个星期,我决定它使用自定义搜索栏:下面我code:
I faced the same issue this week and I resolved it using a custom SeekBar:following my code:
public class Slider extends SeekBar {
private Drawable mThumb;
public Slider(Context context) {
super(context);
}
public Slider(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void setThumb(Drawable thumb) {
super.setThumb(thumb);
mThumb = thumb;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (event.getX() >= mThumb.getBounds().left
&& event.getX() <= mThumb.getBounds().right
&& event.getY() <= mThumb.getBounds().bottom
&& event.getY() >= mThumb.getBounds().top) {
super.onTouchEvent(event);
} else {
return false;
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
return false;
} else {
super.onTouchEvent(event);
}
return true;
}}
希望这有助于
Hope this helps
这篇关于禁用进度变化时,在搜索栏的安卓用户单一的水龙头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!