Android Question swipe and imageview and keep touch/tap event?

kanaida

Active Member
Licensed User
Longtime User
I just made a pretty complex activity with more views than I can count.

It's basically like a product page in a store type app with a fixed number of views, the idea was when a product image is clicked, i load the details on the right. That works fine. However now I wanted to use swipe left/right to change pages. Got that working too. Except When that's enabled it captured the touch/tap event so now my button event won't fire. Then I saw by accident the touch image view. Hoping i can add the swipe ability without sacrificing the event.

I also tried it on the activity, however it's underneath everything so it's really hard to touch in the first place to swipe.

any ideas?

It looks like the Gesture Overlay would provide the perfect solution, but I don't really see any threads on it.
http://developer.android.com/reference/android/gesture/GestureOverlayView.html
 

kanaida

Active Member
Licensed User
Longtime User
What i was thinking was replacing all of them via search and replace, but not sure about the designer files... ugh. it would all work though, just handled all by one touch event that swipes a page. any way to do that?
 
Upvote 0

kanaida

Active Member
Licensed User
Longtime User
I tried that library, but it doesn't forward the click event to my buttons. It seems to grab the entire screen's touch events or something along those lines, my swipe worked fine. Here's the code I had.

I know I can handle the touch event, and I could theoretically call the click but i'd have to compare a gazillion left and top properties of A LOT of views >40. Just seeing if there's any way around that.

B4X:
Sub ptouch_Touch (Action As Int, x As Float, Y As Float)

    Select Action
   
        Case Activity.ACTION_DOWN
            startX = x
            startY = Y
           
        Case Activity.ACTION_UP
            If Abs(Y - startY) > 10%y Then Return
            If x - startX > 10%x  Then
                Log("swipe left")
                StylePage = StylePage -1
                ChangeStylePage
               
            Else If startX - x > 10%x  Then
                Log("swipe right")
                StylePage = StylePage +1
                ChangeStylePage
               
            End If
    End Select

End Sub
 
Upvote 0
Top