B4A Class [B4X] B4XSwitch to support Accessibility

I think that the B4XSwitch does not support accessibility very well. I made a simple extension based on the already extended version of the B4XSwitch that supports setting colors at runtime. (Many thanks to @Blueforcer.) Now you can add a description to the panel, which is read out correctly by TalkBack.

Example:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    
    Acc.SetContentDescription(B4XSwitchAcc1.Panel, "This is a switch. It is currently " & IIf(B4XSwitchAcc1.Value, "on.", "off."))
End Sub

Private Sub B4XSwitchAcc1_ValueChanged (Value As Boolean)
    Acc.SetContentDescription(B4XSwitchAcc1.Panel, "This is a switch. It is currently " & IIf(B4XSwitchAcc1.Value, "on.", "off."))
End Sub

Just replace it inside your XUI Views.b4xlib. You can also rename the class to use it beside the official XUI Views. Maybe this can be added in future official updates.
 

Attachments

  • B4XSwitchAccessibility.zip
    10.6 KB · Views: 42
  • B4XSwitchAcc.bas
    5.5 KB · Views: 69
Top