Android Question It possible add click image in ImageSlider??

nickysuwandi

Member
Licensed 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
 

aeric

Well-Known Member
Licensed User
You can add a transparent panel on top of the image slider.
 

Erel

Administrator
Staff member
Licensed 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
 

nickysuwandi

Member
Licensed 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
 

aeric

Well-Known Member
Licensed 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
 
Top