B4A Class Switch view (Android 4+)

upload_2014-3-18_9-44-0.png


This class wraps the native Switch view using JavaObject. This view was added in Android 4+. You can either add the view with the designer as a CustomView (don't forget to set Custom Type field) or add it by code.

See the attached example.

Edit: Switch is available in the ViewsEx library.
 
Last edited:
Hi Erel,

I also added the switch view to my current app I'm working on as a CustomView in the designer and the result of using:

Code:
    SwMute.TextOff = "Normal"
    SwMute.TextOn = "Muted"

Is the same. The text does not show up.

For now I think I will need to use a Label view and alter the text on that based on the true and false checked value of the switch view.

Here's the screen shot.
No text on switch views.png
 
Last edited:
Which device are you using? The switch appearance is non-standard.

Hi,

It's a Chinese replica phone model SM-G900.

The phone is a clone of the Samsung S5 and is running Jellybean modified to look like KitKat.
 
Add visible function ?

Code:
Dim sw As SwitchView
------------------------------
sw.visible = false

#5:

Code:
sw.Switch.Visible = false
 
Last edited:
Please, Do you have a solution for typeface ?

sw.typeface and sw.switch.typeface = not possible, and I need to change character for sw.TextOff = " "
 
Thanks Erel

But how possible enlarge text ? I'm not sure txt take typeface
 
Yes, but I need enlarge character, I have a doubt if I use my own typeface

Export as zip when uploading projects = sorry
 

Attachments

Back
Top