Android Question It possible add click image in ImageSlider??

nickysuwandi

Member
Licensed User
Longtime User
I had using Image Slider from Erel, very good

B4X:
https://www.b4x.com/android/forum/threads/b4x-xui-imageslider.87128/

I had problem to display image description.

It possible to add click image in ImageSlider, so each time user click the selected image, we can display the description of the image?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code is responsible for the sliding gesture:
B4X:
Private Sub WindowBase_Touch (Action As Int, X As Float, Y As Float)
   If Action = WindowBase.TOUCH_ACTION_DOWN Then
       MousePressedX = X
   Else If Action = WindowBase.TOUCH_ACTION_UP Then
       If X > MousePressedX + 50dip Then
           PrevImage
       Else if X < MousePressedX - 50dip Then
           NextImage
       Else '<------------------ add this
           CallSub(mCallback, mEventName & _Click")
       End If
   End If
End Sub
 
Upvote 0

nickysuwandi

Member
Licensed User
Longtime User
Thanks Erel, i follow you code and i add this line

B4X:
Private Sub WindowBase_Touch (Action As Int, X As Float, Y As Float)
    If Action = WindowBase.TOUCH_ACTION_DOWN Then
        MousePressedX = X
    Else If Action = WindowBase.TOUCH_ACTION_UP Then
        If X > MousePressedX + 50dip Then
            PrevImage
        Else if X < MousePressedX - 50dip Then
            NextImage
        Else '<------------------ add this
            CallSub2(mCallBack,  mEventName & "_Click",CurrentIndex)
        End If
    End If
End Sub
'
Private Sub Click(index As Int)
    Return index
End Sub

I got the index of picture we clicked
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Thanks Erel, i follow you code and i add this line

B4X:
Private Sub WindowBase_Touch (Action As Int, X As Float, Y As Float)
    If Action = WindowBase.TOUCH_ACTION_DOWN Then
        MousePressedX = X
    Else If Action = WindowBase.TOUCH_ACTION_UP Then
        If X > MousePressedX + 50dip Then
            PrevImage
        Else if X < MousePressedX - 50dip Then
            NextImage
        Else '<------------------ add this
            CallSub2(mCallBack,  mEventName & "_Click",CurrentIndex)
        End If
    End If
End Sub
'
Private Sub Click(index As Int)
    Return index
End Sub

I got the index of picture we clicked
I thought can use like this in Form code:
B4X:
Sub ImageSlider1_Click(Index As Int)
    Log (Index)
End Sub
 
Upvote 0
Top