3

In order to have list reordering functionality I turned to this implementation.

My problem is that when I try to drag an item in my ListView, I don't get the ACTION_DOWN event. Instead, for a single smear down motion I get 2 ACTION_MOVE events (action=0x00000002) and a single ACTION_UP event (action=0x00000001) in this order.

I've looked at similar questions but it seems like everyone has the opposite problem, getting only ACTION_DOWN events. Can anyone think of why this is happening?

Thanks, Yoel

yoel
  • 305
  • 4
  • 17

2 Answers2

2

It turns out I needed to add this small piece of code:

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    return super.onInterceptTouchEvent(ev);
}

Now I get the ACTION_DOWN events in the OnTouchEvent function and it all works fine.

yoel
  • 305
  • 4
  • 17
2

I was using the same code.

My problem was also that something was consuming the event and I didn't managed to found what was it... but i managed to solve it using onInterceptTouchEvent to return true on the events i needed on onTouchEvent.

Problem solved :-)

neteinstein
  • 17,529
  • 11
  • 93
  • 123
  • Thanks a lot for the reply! Indeed this helped. I made both events to invoke the same function and I see some action. – yoel Apr 03 '12 at 14:17
  • I override onInterceptTouchEvent and filter the MotionEvent actions I am interested (ACTION_DOWN and ACTION_MOVE). In the method with those actions, it calls onTouchEvent and return false. If I do not filter the action events, then it calls super.onInterceptTouchEvent(ev) method. – The Original Android Apr 21 '15 at 20:18