Seekbar Userchange Questions

tcgoh

Active Member
Licensed User
Longtime User
Hi,

I have search the forum, but could not get a simple code for the above. Could someone help?

I am trying the get the value of the seekbar to be displayed in a label box when the userchange the seekbar position.

B4X:
Sub seekbar1_Valuechange ( Value As Int, userchange As Boolean)
   If userchange Then
      label.Text = Value
   End If

End Sub


?? thanks
 

tcgoh

Active Member
Licensed User
Longtime User
What's the problem, your code is right.
You just need to make sure that the Label you are refering to, is in a layout or defined in the code.

Best regards.

Hi Klaus,


Thanks Klaus for the quick reply.
But I'm NOT getting any "value" in my label box, here is my code
B4X:
Sub Globals
   Dim lblto As Label
   Dim seekbar1 As SeekBar
End Sub

Sub Activity_Create(FirstTime As Boolean)
   lblto.Initialize("lblto")
   Activity.LoadLayout("Main")
   lblto.SetLayout(5%x,75%y,15%x,7%y)
      
   seekbar1.Max = 100
   
End Sub

Sub seekbar1_Valuechange ( Value As Int, userchange As Boolean)
   If userchange Then
      lblto.Text = Value
   End If
End Sub

What am I missing?:BangHead:
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
If lblto is already defined in the layout file you must remove this line, because lblto is alraed initialized when the layout file is loaded :
B4X:
lblto.Initialize("lblto")
Best regards.


It is still NOT working??

Regards
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
The signature for your event sub is ALSO wrong.
The better way to debug these problems is to add a log when entering or exiting an event so you know that is actually fires.

B4X:
ValueChanged (Value As Int, UserChanged As Boolean)

OK that did it. Great thanks.

:sign0098:
 
Upvote 0
Top