Android Question B4XSeekBar Steps

Jorge M A

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

stevel05

Expert
Licensed 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.
 

stevel05

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

stevel05

Expert
Licensed 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.
 
Top