Android Question (Solved) Need help with my checkbox logic

edm68

Member
Licensed User
Longtime User
Hi,
I can't seem to figure this out.
I have 4 checkboxes, the top one "chkAll" checks or unchecks the others depending on if it is checked. If I uncheck one of the others it should uncheck the chkAll checkbox. Likewise, if I check the others & chkAll is not checked it should check itself. I hope that all makes sense.
I have my test project working as expected in debug mode, but seems to have random results in release mode.
In debug mode I do get the following in red in the logs the first time I uncheck a checkbox. From what I can find in the forum it's not something I need to worry about? It does say to check the unfiltered logs, but everything scrolls by so fast I don't know what to look for.
log:
Unexpected event (missing RaiseSynchronousEvents): chkevents_checkedchange
Check the unfiltered logs for the full stack trace.
I've attached a small test project.

Thanks in advance for any help.
 

Attachments

  • chkTest.zip
    9.6 KB · Views: 247

agraham

Expert
Licensed User
Longtime User
If you put #BridgeLogger: True you will see in release mode that you get multiple change events when you change a checkbox state in code. You can trap this by having a global variable that you check and set on entry and clear on exit. It doesn't totally work with your current logic but my mind is a bit fuzzy this morning so I'll leave that for you to sort out :)

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    ' ...
    Private Changing As Boolean = False
End Sub

Private Sub chkEvents_CheckedChange(Checked As Boolean)
    Log("chkEvents started")
    If Changing Then
        Log("Returning")
         Return         
    End If
    Changing = True
    ' ...
    Changing = False
End Sub
 
Upvote 0
Top