Hi, I want to create a custom dialog with a seekbar.
If you move the seekbar i want to show the actual value on a label.
I tried it with a ValueChanged sub but this sub is only called if I close the dialog not when the dialog is shown. What's wrong?
Here is the code:
Thanks for your help.
If you move the seekbar i want to show the actual value on a label.
I tried it with a ValueChanged sub but this sub is only called if I close the dialog not when the dialog is shown. What's wrong?
Here is the code:
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim btnCustom As Button
Dim lbl1, lbl_Test As Label
Dim SeekBar1 As SeekBar
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
lbl_Test.Text = ""
SeekBar1.Initialize("SeekBar1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnCustom_Click
Dim cd As CustomDialog2
Dim cd_pnl As Panel
cd_pnl.Initialize("cd_pnl")
'Seekbar
Dim seek As SeekBar
seek.Initialize("seek")
lbl1.Initialize("")
seek.Max = 100
seek.Value = 50
cd_pnl.AddView(seek, 10dip, 45dip, 77%x-20dip, 30dip )
'Label
lbl1.Initialize("")
lbl1.Gravity = Gravity.CENTER
lbl1.Text = seek.Value & "%"
lbl1.TextColor = Colors.LightGray
lbl1.TextSize = 18
lbl1.Typeface = Typeface.DEFAULT
cd_pnl.AddView(lbl1, 10dip, 10dip, 77%x-20dip, 25dip)
cd.AddView(cd_pnl, 77%x, 90dip)
ret = cd.Show("Test", "Yes", "No", "Maybe", Null)
End Sub
'Seekbaar Value Changed in Dialog
Sub seek_ValueChanged (Value As Int, UserChanged As Boolean)
lbl1.Text = Value & "%"
End Sub
'To test it in "normal" view
Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
lbl_Test.Text = Value & "%"
End Sub
Thanks for your help.