我的 Android 视图如何停止事件?
How my Android view can stop events?
我创建了一个水平轮子视图。它运行良好,但是当我把它放在 Wizardroid 的一个步骤中时,在制作滑动页面的滚轮时。
如何解决?
我的代码 onTouchEvent
:
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
int maskedAction = event.getActionMasked();
switch (maskedAction) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: {
lastPosX = event.getX();
break;
}
case MotionEvent.ACTION_MOVE: { // a pointer was moved
isScrolling = true;
float eventX = event.getX();
float mouvmentDistance = (lastPosX - eventX) * mouvmentRatio;
if (Math.abs(mouvmentDistance) > distance) {
}
newValue = (float)(selectedValue + Math.floor(mouvmentDistance) * step);
decallage = (float)((lastPosX - eventX) - (Math.floor(mouvmentDistance)));
if (newValue > maxValue)
newValue = maxValue;
if (newValue < minValue)
newValue = minValue;
this.setValue(newValue, true);
break;
}
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
isScrolling = false;
this.setValue(newValue, false);
break;
}
return true;
}
我通过 SeekBar
扩展我的观点解决了这个问题
我创建了一个水平轮子视图。它运行良好,但是当我把它放在 Wizardroid 的一个步骤中时,在制作滑动页面的滚轮时。 如何解决?
我的代码 onTouchEvent
:
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
int maskedAction = event.getActionMasked();
switch (maskedAction) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: {
lastPosX = event.getX();
break;
}
case MotionEvent.ACTION_MOVE: { // a pointer was moved
isScrolling = true;
float eventX = event.getX();
float mouvmentDistance = (lastPosX - eventX) * mouvmentRatio;
if (Math.abs(mouvmentDistance) > distance) {
}
newValue = (float)(selectedValue + Math.floor(mouvmentDistance) * step);
decallage = (float)((lastPosX - eventX) - (Math.floor(mouvmentDistance)));
if (newValue > maxValue)
newValue = maxValue;
if (newValue < minValue)
newValue = minValue;
this.setValue(newValue, true);
break;
}
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
isScrolling = false;
this.setValue(newValue, false);
break;
}
return true;
}
我通过 SeekBar