0

So I have a selector on a list view, where each row has 2 text views and each text view has another selector in sync(different drawables for the same states: activated and pressed) with the one on the list. My logic is when I detect a fling on an item in the list view, I temporarily change the background color of that view and after 500ms set it back to transparent.

But, when it resets sometimes the child view has its pressed state set to true and sometimes not either ways the view has the correct bg but the inner text views always correspond to their activated drawables even when pressed state is false.

I can't seem to figure out how to correct this behavior. Any help is much appreciated, this thing is driving me nuts.

I've tried clearing choices which doesn't help, I've even tried to explicitly force the child view to set false for its activated state and pressed state that doesn't do goo either. I've really run out of options with this.

rahul.taicho
  • 1,339
  • 1
  • 8
  • 18

1 Answers1

0

So after spending much time analyzing what is going on behind the scenes in AbsListView I found a workaround for this problem. First more on the problem which was causing this, the AbsListView has got 8 states for motion detection namely -

  1. TOUCH_MODE_REST (-1)
  2. TOUCH_MODE_DOWN (0)
  3. TOUCH_MODE_TAP (1)
  4. TOUCH_MODE_DONE_WAITING (2)
  5. TOUCH_MODE_SCROLL (3)
  6. TOUCH_MODE_FLING (4)
  7. TOUCH_MODE_OVERSCROLL (5)
  8. TOUCH_MODE_OVERFLING (6)

and when the ACTION_UP event was being dispatched to the list view somehow its touchMode was getting stuck between (2) and (5) causing it to remember its pressed state on the motionView(Child view) which was causing incorrect results i.e. the pressed state as visible even when the motion had finished.

I couldn't get clarity on why this issue was there in the first place as I was always dispatching the event from my TouchListener to the ListView.

Anyhow now the work around for such cases -

When my GestureDetector recognizes a gesture it will return true so all I had to do was when the GestureDetector returns true just change the MotionEvent's action to ACTION_CANCEL and dispatch it to the ListView and voila, problem solved.

rahul.taicho
  • 1,339
  • 1
  • 8
  • 18