Android Question [RESOLVED] B4XDialog - Setting ToggleButton States - No working correctly

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hello

I have the following code:

B4X:
Sub runtime_settings_access
  
   Dim p As B4XView = xui.CreatePanel("")
  
   p.SetLayoutAnimated(0, 0, 0, 90%x,270dip)
   p.LoadLayout("runtime_settings")

   ' // create the dialog
   dialog.Initialize(Activity)
   dialog.BackgroundColor = Colors.White
   dialog.TitleBarColor = 0xFFC8001F
   dialog.TitleBarTextColor = Colors.white
   dialog.Title = "Options"
   dialog.ButtonsColor = Colors.Gray
   dialog.ButtonsTextColor = Colors.black
   dialog.PutAtTop = True 'put the dialog at the top of the screen
   dialog.ShowCustom(p, "OK", "", "")
  
   draw_user_options
   set_user_access_permissions
   ' // wait for response
   Wait For (dialog.ShowCustom(p, "OK", "", "")) Complete (Result As Int)
  
  
End Sub

Public Sub draw_user_options
  
  
   ' // lone working
   If APPSET.RT_am.worktype = 1 Then
       tbWorkType.Checked = True
   Else
       tbWorkType.Checked = False
   End If
   ' // mandown
   If APPSET.licence.FEATURE(APP_FEATURE.mandown) Then
       If APPSET.mandown.enabled = 1 Then
           tbManDown.Checked = True
       Else
           tbManDown.Checked = False
       End If
   Else
       lblManDown.Color = Colors.red
       tbManDown.Enabled = False
   End If
          
   ' // audio warnings
   If APPSET.RT_am.audio_warnings = 1 Then
       tbAudibleWarnings.Checked = True
   Else
       tbAudibleWarnings.Checked = False
   End If
   ' // vibration warnings
   If APPSET.RT_am.vibration_warnings = 1 Then
       tbVibrationWarnings.Checked = True
   Else
       tbVibrationWarnings.Checked = False
   End If

End Sub

Sub set_user_access_permissions
  
   Log("set_user_access_permissions")
   ' // LW State permission
   If APPSET.userLWswitch = 1 Then
       Log("tbWorkType.Enabled = True")
       tbWorkType.Enabled = True
       tbWorkType.visible = True
   Else
       Log("tbWorkType.Enabled = False")
       tbWorkType.Enabled = False
       tbWorkType.visible = False
   End If
   ' // MD State permission
   If APPSET.userMDswitch = 1 Then
       Log("tbManDown.Enabled = True")
       tbManDown.Enabled  = True
   Else
       Log("tbManDown.Enabled = False")
       tbManDown.Enabled  = False
   End If
   ' // AUDIO/VIBRATION Permission
   If APPSET.uwc_notify = 1 Then
       Log("APPSET.uwc_notify = 1")
       tbAudibleWarnings.Enabled = False
       tbVibrationWarnings.Enabled = False
   Else
       Log("APPSET.uwc_notify = 0")
       tbAudibleWarnings.Enabled = True
       tbVibrationWarnings.Enabled = True
   End If

End Sub

when executed, setting the enabled state of the toggle button to false does not work, but I can set the visibility to false as it does work, is this a bug ?

Using b4a 9.3


Regards

John.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hello

Attached is the sample you requested with the actual bal file used in the original app. I have included the visibility test also to demonstrate the issue.

Regards

John.
 

Attachments

  • test_dialog.zip
    11.7 KB · Views: 158
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
You need to do it like this:
B4X:
Dim sf As Object = dialog.ShowCustom(p, "OK", "", "")
set_user_access_permissions
Wait For (sf) Complete (Result As Int)
Somewhere in B4XDialog code it enables the underlying controls when you call Show.

Thanks for the help Erel, I think I will use the switch's going forward :)
 
Upvote 0
Top