Android Question B4XSeekBar Steps

Jorge M A

Well-Known Member
Licensed User
Longtime User
The effect is not smooth, if you drag the knob.

B4X:
Sub B4XSeekBar1_ValueChanged (Value As Int)
    B4XSeekBar1.Value = Round (Value/10) * 10
    Log("Value: " & B4XSeekBar1.Value)
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You can get it to snap on mouse release by adding a listener to the basepane of the seekbar:

B4X:
    Dim Jo As JavaObject = B4XSeekBar1.mBase
    Dim O As Object = Jo.CreateEventFromUI("javafx.event.EventHandler","Seekbar",Null)
    Jo.RunMethod("setOnMouseReleased",Array(O))

Then adding Jorge's code to the mouse released event callback:
B4X:
Sub SeekBar_Event (MethodName As String, Args() As Object) As Object
    B4XSeekBar1.Value = Round (B4XSeekBar1.Value/10) * 10
    Log("Value: " & B4XSeekBar1.Value)
End Sub

Not much different but it's a little nicer experience maybe.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Ooops sorry, just realized it's B4a, will look for the correct code.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Hmm, sorry it seems that this option is not available for B4a, the touch listener is in use by the Seekbar, we can't listen to it and use the seekbar.
 
Upvote 0
Top