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

  • Sample1.zip
    9.1 KB · Views: 710
  • SD_Switch 0.03.zip
    49.2 KB · Views: 709
Last edited:

Peter Simpson

Expert
Licensed User
Longtime 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...
 

Star-Dust

Expert
Licensed User
Longtime User
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:

Star-Dust

Expert
Licensed User
Longtime User
Update rel 0.03

Add new Switch
 

ThRuST

Well-Known Member
Licensed User
Longtime User
@Star-Dust Real nice. EXCELLENTE. I assume I can use it for free without making a clone in assembly language hahaha:D
 

ThRuST

Well-Known Member
Licensed User
Longtime User
I noticed the sample is for B4A!!! Will it work on B4J as well?
 

Star-Dust

Expert
Licensed User
Longtime User
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
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Any advice about the process you used? I'd like to learn your way.
 

eps

Expert
Licensed User
Longtime User
Hi

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

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

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

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

Star-Dust

Expert
Licensed User
Longtime User
Hi

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

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

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

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

eps

Expert
Licensed User
Longtime 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.

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

eps

Expert
Licensed User
Longtime 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?

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