Hello,
I don't know why but in one of my application i use 5 toggle buttons like radio buttons.
The choice for toggle buttons is needed and it's more beautiful for design.
But they stay to don't work like radio buttons as far as i know.
For manage this, i use the code below who take care of the two states, Checked or not. Because i don't want that all toggle buttons can be off, that's not logical. And i want to display a message when the user touch a second time the toggle button even if this color is already set.
I don't know why, but recursive call happen only one time, even if i set the 4 other toggle buttons unchecked in the same part of code ?
(The log allow to verify it)
Edit :
The recursive call happen only when i touch a toggle button who is not checked.
If it's checked there are no recursive call ?
That seems weird.
Erel maybe could take a look, and explain why one time only.
This happen with a Genymotion virtual device and i work with B4A v3.8
I haven't tested that with another configuration.
Regards, Laurent
I don't know why but in one of my application i use 5 toggle buttons like radio buttons.
The choice for toggle buttons is needed and it's more beautiful for design.
But they stay to don't work like radio buttons as far as i know.
For manage this, i use the code below who take care of the two states, Checked or not. Because i don't want that all toggle buttons can be off, that's not logical. And i want to display a message when the user touch a second time the toggle button even if this color is already set.
B4X:
Sub toggleColor_CheckedChange(Checked As Boolean)
'only here for play a sound when the user push twice on the checked toggle
If Not(Checked) Then
playSound.Initialize
playSound.Load(File.DirAssets,"bad.mp3")
End If
Dim b As String, Send As View
Send=Sender
b=Send.Tag
'I use the tag property and the same Event
Log("B Tag is " & b & " checked is " & Checked & " thisColor is " & thisColor)
Select Case b
Case "0" 'Green
If Checked AND thisColor <> 0 Then
thisColor = 0
togColorPink.Checked = False
togColorBlue.Checked = False
TogColorMagenta.Checked = False
TogColorYellow.Checked = False
Else If Not(Checked) AND thisColor = 0 Then
togColorGreen.Checked=True
togColorPink.Checked = False
togColorBlue.Checked = False
TogColorMagenta.Checked = False
TogColorYellow.Checked = False
playSound.Play
End If
Case "1" 'Pink
If Checked AND thisColor <> 1 Then
thisColor = 1
togColorGreen.Checked = False
togColorBlue.Checked = False
TogColorMagenta.Checked = False
TogColorYellow.Checked = False
Else If Not(Checked) AND thisColor = 1 Then
togColorGreen.Checked = False
togColorPink.Checked=True
togColorBlue.Checked = False
TogColorMagenta.Checked = False
TogColorYellow.Checked = False
playSound.Play
End If
Case "2" 'Blue
If Checked AND thisColor <> 2 Then
thisColor = 2
togColorGreen.Checked = False
togColorPink.Checked = False
TogColorMagenta.Checked = False
TogColorYellow.Checked = False
Else If Not(Checked) AND thisColor = 2 Then
togColorGreen.Checked = False
togColorPink.Checked = False
togColorBlue.Checked=True
TogColorMagenta.Checked = False
TogColorYellow.Checked = False
playSound.Play
End If
Case "3" 'Magenta
If Checked AND thisColor <> 3 Then
thisColor = 3
togColorGreen.Checked = False
togColorPink.Checked = False
togColorBlue.Checked = False
TogColorYellow.Checked = False
Else If Not(Checked) AND thisColor = 3 Then
togColorGreen.Checked = False
togColorPink.Checked = False
togColorBlue.Checked = False
TogColorMagenta.Checked=True
TogColorYellow.Checked = False
playSound.Play
End If
Case "4" 'Yellow
If Checked AND thisColor <> 4 Then
thisColor = 4
togColorGreen.Checked = False
togColorPink.Checked = False
togColorBlue.Checked = False
TogColorMagenta.Checked = False
Else If Not(Checked) AND thisColor = 4 Then
togColorGreen.Checked = False
togColorPink.Checked = False
togColorBlue.Checked = False
TogColorMagenta.Checked = False
TogColorYellow.Checked=True
playSound.Play
End If
End Select
'Do something after color index is set
End Sub
I don't know why, but recursive call happen only one time, even if i set the 4 other toggle buttons unchecked in the same part of code ?
(The log allow to verify it)
Edit :
The recursive call happen only when i touch a toggle button who is not checked.
If it's checked there are no recursive call ?
That seems weird.
Erel maybe could take a look, and explain why one time only.
This happen with a Genymotion virtual device and i work with B4A v3.8
I haven't tested that with another configuration.
Regards, Laurent
Last edited: