How my Android view can stop events?

33 views Asked by At

I created a view that is a horizontal wheel. It function well but when I put it in a step of Wizardroid, when making the scroll wheel that swipe the page. How to solve this?

My code 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;
}
1

There are 1 answers

0
Vincent Segaert On BEST ANSWER

I solved the problem by extend my view with a SeekBar