B4J Library B4j ToggleSwitch

This is a simple start for a Toggleswitch Customview for B4j. It is deliberately not a B4X Customview as I wanted it to be styleable via CSS.

upload_2018-11-6_22-42-44.png

​
The animation duration is set, but you could very easily add a designer property to allow changing it in the Designer. The 3 components can be styled in the css file included in the project.

Don't forget to add the Stylesheet to an appropriate place.
 

Attachments

Last edited:
Hi Roger,

This thread just contains a very basic implementation that anybody can use as a template and change as they wish. If you want to share your modified version, feel free to do so in a new thread and explain what you have changed.

BTW, there is a small error (check the log window) that should be addressed before you share it.
 
ok I should update my previous post, sorry for taking advantage of your code.
I do like my addions, it made it a bit better in fact :)
 
What bug are you talking about? Both of our code is perfect. Or are you trying to tell me something else?
What if I'm Tuco's brother in Breakin' bad Steve (Netflix success TV series) hahaha
 
Oops sorry I totally missed that. Thanks for notifying me. I will update my post with v1.1
 
Hi Steve. I updated my changes to v1.2 which should be the best yet.
 
Hi again Steve, I couldn't let go of it. I updated your library to v1.3 :D

See my post #19 to find it.
 
Steve, it would be nice with a fading effect on the text everytime the button is clicked. How to do that :rolleyes:
 
Steve, do you mind adding calls to these subs in your class. It will save me alot of time if you do it. Thanks

Code:
Public Sub FadeIn
    TSLbl.SetAlphaAnimated(mDuration /2, 1)
End Sub

Public Sub FadeOut
    TSLbl.SetAlphaAnimated(mDuration /2, 0)
End Sub
 
Hi, I'm trying to use your lib on B4X Pages project.
In my first page it works, but when i close it and open another B4XPage, it doens't show button switch:

in my AppStart it works, but when i close this layout and open a new one it doesn't show button switch, but only text!

[CODE lang="b4x" title="AppStart"]MainForm = Form1
MainForm.Stylesheets.Add(File.GetUri(File.DirAssets,"ToggleSwitch.css"))
MainForm.Show[/CODE]

[CODE lang="b4x" title="OnClick new page"]B4XPages.ShowPageAndRemovePreviousPages("NewPage")[/CODE]

could you help me?
 
Last edited:
Sorry I somehow missed this post, did you get it fixed? If not post a project showing the problem.
 
Back
Top