Android Question CustomListView vertical scroll overrides GestureDetector fling capture

Jimdriver2

Member
Licensed User
Longtime User
On my app I've got a full screen CustomListView I'm using vertically and adding panels to, much like the cards in the tutorial example.

What I need to have however is the ability to swipe left and right on that CLV and cause it to load in a different set of panels.

I've added a GestureDetector object and whilst that works fine capturing the 'fling' event on a temporary static panel I added to the top of the screen. So I know I'm using that correctly.

However I can't get the GestureDetector to work on the CLV or any of the Views I add to it. I've tried doing what the GestureDetector example does and adding the whole Activity as a listener. That didn't seem to do anything. CLV's can't be added as listeners. I tried adding the GestureDetector to the different Views I add to my CLV. The panels I'm adding have a few different labels and an ImageView on them. I added the GestureDetector to all of them but it's not really working. Ever so often some fling events get captured but mostly they don't. I've two theories why:

1. the Views are fairly small and therefore there isn't enough space 'in them' for a fling to be correctly interpreted

2. the CLV seems to read almost any motion happening as a vertical scroll and it captures that touch event. (Hence my title of this thread)

Ideally I need something that for the whole activity, no matter what View is being touched, a swipe or fling event will be captured by my GestureDetector.

Is there any way to make the GestureDetector the top priority for touch events?

Thanks.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Jimdriver2

Member
Licensed User
Longtime User
Ok thanks Erel. I gave them a quick look and it seems like it would need to be a case of doing something with a TouchPanelCreator as you've done in the Sliding Drawer class. I think I'd have to sort of replicate what you've done in that class, but rather than have it show a menu it would need to provide an event where code can do the actions I want.

It's possibly a bit more fiddly than I initially anticipated so I might hold off for now and see if I can figure out some other way of implementing the similarly functionality. I'm surprised capturing touch behaviour is still as tricky in Android and requires such a kind of low level shaping of the structure of your activity.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…