Swipe gestures on Android ListView items
Posted
by
Bartek
on Stack Overflow
See other posts from Stack Overflow
or by Bartek
Published on 2013-07-03T11:03:21Z
Indexed on
2013/07/03
11:05 UTC
Read the original article
Hit count: 454
I have a ListView populated by a ResourceCursorAdapter. I use the loaders mechanism to query a ContentProvider for list items. I detect swipe gestures on the list items to perform some actions on them. New items get added by a background service, so the list can change dynamically.
Everything works fine, except when I start swiping and a database change occurs (as a result of the background service adding a new row). In such case the gesture is not detected properly. I noticed that ACTION_CANCEL is dispatched to the list item view and also that bindView is executed for all visible items. Inside the bindView method I only set some text - I don't change any listeners there.
How can I make gestures work even when new items are being added by the background service? Perhaps there's a way to prevent the motion from being cancelled or I can pause database updates so they don't interrupt the gesture.
© Stack Overflow or respective owner