B4A Library SD Switch

Discussion in 'Additional libraries, classes and official updates' started by Star-Dust, Aug 22, 2018.

  1. Star-Dust

    Star-Dust Expert Licensed User



    Author: Star-Dust
    Version: 0.03
    • SDSwitch
      • Events:
        • ChangeValue (Value As Boolean)
      • Functions:
        • Class_Globals As String
        • DesignerCreateView (Base As Panel, Lbl As Label, Props As Map) As String
        • GetBase As Panel
        • Initialize (Callback As Object, EventName As String) As String
        • IsInitialized As Boolean
          Verifica se l'oggetto sia stato inizializzato.
      • Properties:
        • Value As Boolean

    Attached Files:

    Last edited: Aug 22, 2018
    GMan, BPak, stevel05 and 17 others like this.
  2. Peter Simpson

    Peter Simpson Expert Licensed User

    Nice looking switches my personal favourite is the bottom one.

    Just one question though.
    Do you ever sleep or are there two of you, whilst one sleeps the other one codes ;)

    Nice one, but have a break, have a KitKat, oh yes and some nice wine...
    JakeBullet70 and Johan Hormaza like this.
  3. Star-Dust

    Star-Dust Expert Licensed User

    I do the views in the scraps of time. But if I had a duplicate of me it would not be bad ;)

    One would develop for Android and the other for IOS
    Last edited: Aug 22, 2018
  4. Mashiane

    Mashiane Expert Licensed User

    Thanks for the star-dust, it will make us stars too when developing our UIx. You are really a star mate!
    Johan Hormaza likes this.
  5. Star-Dust

    Star-Dust Expert Licensed User

    Update rel 0.03

    Add new Switch
    inakigarm likes this.
  6. ThRuST

    ThRuST Well-Known Member Licensed User

    @Star-Dust Real nice. EXCELLENTE. I assume I can use it for free without making a clone in assembly language hahaha:D
  7. ThRuST

    ThRuST Well-Known Member Licensed User

    I noticed the sample is for B4A!!! Will it work on B4J as well?
  8. Star-Dust

    Star-Dust Expert Licensed User

    No, I'm sorry you have to recreate it in B4J. But it's easy to make it happen
  9. ThRuST

    ThRuST Well-Known Member Licensed User

    Any advice about the process you used? I'd like to learn your way.
  10. eps

    eps Well-Known Member Licensed User


    I wonder if you could help with adding these programmatically please?

    I've added the following but get an error...

    Dim lblSoundSwitch As Label


    Private SDSwitch1 As SDSwitch


    Dim Props As Map









    The error, which is raised on the DesignerCreateView, I get is :

    java.lang.RuntimeException: Cannot parsenull as boolean
        at anywheresoftware.b4a.BA.parseBoolean(BA.java:
        at anywheresoftware.b4a.BA.ObjectToBoolean(BA.java:
        at b4a.example.sdswitch._designercreateview(sdswitch.java:
        at torquesoft.spaceinvaders.main._i_main_button_click(main.java:
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:
        at anywheresoftware.b4a.objects.ViewWrapper$
        at android.view.View.performClick(
        at android.view.View$PerformClick.run(
        at android.os.Handler.handleCallback(Handler.java:
        at android.os.Handler.dispatchMessage(Handler.java:
        at android.os.Looper.loop(Looper.java:
        at android.app.ActivityThread.main(ActivityThread.java:
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    I guess I'm not setting something that the DesignerView is expecting or am I getting something else wrong? Any help would be appreciated, the toggle switches look great, but I'm trying to add them programmatically.
  11. Erel

    Erel Administrator Staff Member Licensed User

    This is not the correct way to work with custom views. Create a layout file with the custom view and load it whenever you want to create one.
    eps and Star-Dust like this.
  12. Star-Dust

    Star-Dust Expert Licensed User

    This view is not meant to be created by code.

    Also parametric steps in the map are not corrected ones. No custom list passes the layout positions on the map.
    Why do you need to do it as a code?
  13. eps

    eps Well-Known Member Licensed User

    Understood - I was just following what I've done for other Views.. I'll give this a whirl!
  14. eps

    eps Well-Known Member Licensed User

    As mentioned - I was looking to follow the same approach as I've used for other views. I'll give the other approach a go - just need to get my head round the different approach that's all, cheers!
    Star-Dust likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice