B4A Library SD Switch

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
 

Attachments

Last edited:
Do you ever sleep or are there two of you, whilst one sleeps the other one codes ;)...
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:
Update rel 0.03

Add new Switch
 
@Star-Dust Real nice. EXCELLENTE. I assume I can use it for free without making a clone in assembly language hahaha:D
 
I noticed the sample is for B4A!!! Will it work on B4J as well?
 
I noticed the sample is for B4A!!! Will it work on B4J as well?
No, I'm sorry you have to recreate it in B4J. But it's easy to make it happen
 
Any advice about the process you used? I'd like to learn your way.
 
Hi

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

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

Code: Copy
    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: Copy
java.lang.RuntimeException: Cannot parse: null 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.
 
Hi

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

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

Code: Copy
    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: Copy
java.lang.RuntimeException: Cannot parse: null 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.
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?
 
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.

Understood - I was just following what I've done for other Views.. I'll give this a whirl!
 
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?

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!
 
Back
Top