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:

rleiman

Well-Known Member
Licensed User
Longtime User
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:

B4X:
    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:

rleiman

Well-Known Member
Licensed User
Longtime User
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.
 

Croïd

Active Member
Licensed User
Longtime User
Add visible function ?

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

#5:

B4X:
sw.Switch.Visible = false
 
Last edited:

Croïd

Active Member
Licensed User
Longtime User
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 = " "
 

Croïd

Active Member
Licensed User
Longtime User
Thanks Erel

But how possible enlarge text ? I'm not sure txt take typeface
 

Croïd

Active Member
Licensed User
Longtime User
Yes, but I need enlarge character, I have a doubt if I use my own typeface

Export as zip when uploading projects = sorry
 

Attachments

  • switchsymbol2.zip
    7.7 KB · Views: 272
Top