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

    Video1.gif

    SD_Switch

    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
    BPak, stevel05, JakeBullet70 and 16 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

    Hi

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

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

    Code:
    Dim lblSoundSwitch As Label

        lblSoundSwitch.Initialize(
    "lblSoundSwitch")

        
    Private SDSwitch1 As SDSwitch
      
        SDSwitch1.Initialize(SDSwitch1,
    "SDSwitch1")

        SDSwitch1.loadInternalBitmap(
    "Blue")



        
    Dim Props As Map

        Props.Initialize

      

        Props.Put(
    "Left","25")  

        Props.Put(
    "Top","45")

        Props.Put(
    "Height","10")

        Props.Put(
    "Width","20")

        Props.Put(
    "Enabled","True")

        Props.Put(
    "Visible","True")


        SDSwitch1.DesignerCreateView(transparentPanel,lblSoundSwitch,Props)
    The error, which is raised on the DesignerCreateView, I get is :

    Code:
    java.lang.RuntimeException: Cannot parsenull as boolean
        at anywheresoftware.b4a.BA.parseBoolean(BA.java:
    607)
        at anywheresoftware.b4a.BA.ObjectToBoolean(BA.java:
    677)
        at b4a.example.sdswitch._designercreateview(sdswitch.java:
    63)
        at torquesoft.spaceinvaders.main._i_main_button_click(main.java:
    1319)
        at java.lang.reflect.Method.invoke(Native Method)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    191)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
    175)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:
    171)
        at anywheresoftware.b4a.objects.ViewWrapper$
    1.onClick(ViewWrapper.java:80)
        at android.view.View.performClick(
    View.java:6256)
        at android.view.View$PerformClick.run(
    View.java:24779)
        at android.os.Handler.handleCallback(Handler.java:
    789)
        at android.os.Handler.dispatchMessage(Handler.java:
    98)
        at android.os.Looper.loop(Looper.java:
    180)
        at android.app.ActivityThread.main(ActivityThread.java:
    6950)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:
    240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    835)
    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.
Loading...
  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