B4A Library SlideSwitch V1.0.2

SlideSwitch
Version:
1.02
  • SlideSwitch
    Events:
    • close (swview as Object As , token as Object As )
    • onClick (swview as Object As )
    • open (swview as Object As , token as Object As )
    Fields:
    • ba As BA
    Methods:
    • AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
      Set the Color for the SlideSwitch
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Rounded As Boolean [write only]
      Set this to true if you want to get an rounded SlideSwitch
      Default is false
    • State As Boolean
      The State of the the SlideSwitch
      If true the Switch is open
      false if Switch is closed
    • Tag As Object
    • Token As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int

SlideSwitch001.png
 

Attachments

  • libSlideSwitch1.0.0.zip
    8.9 KB · Views: 433
  • SlideSwitchEx.zip
    64.6 KB · Views: 636
  • libSlideSwitch1.0.1.zip
    9.4 KB · Views: 395
  • libSlideSwitch1.0.2.zip
    10.4 KB · Views: 628
Last edited:

DonManfred

Expert
Licensed User
Longtime User
but i cannot slide to end exactly
Check the threshold set... The default is 0.7 which means on 70% you get the confirmed event... Set it to 0.99 or maybe 1.0

For any new question please start a new thread in the questionforum as the question belong not to this thread. SlideSwitch
 

devmobile

Active Member
Licensed User
Check the threshold set... The default is 0.7 which means on 70% you get the confirmed event... Set it to 0.99 or maybe 1.0

For any new question please start a new thread in the questionforum as the question belong not to this thread. SlideSwitch
Why do you are best man?:p:)
 

devmobile

Active Member
Licensed User
Does that mean it is working for you now?
Yes
But it have 3 bug
1.It raise event Press and cancel when user click on it (no swipe)
2.If user click on middle it and swipe it and swipe it,Confirm event to raised because user have to swipe it to out of view
3.We cannot change default background,at the moment it is transparent and i cannot change it
 

NetChain

Member
Thanks for a nice example.

One of the most important differences between a simple toggle switch and the slider switch is the very fact that you have to slide it to engage, instead of just touching it. It's nice that you made your switch sliding upon touching it, but that deceives the purpose of the sliding switch. I mean now it's just a toggle switch with a visual effect, but I wouldn't call it a slider switch.

Unfortunately you can not use this switch in apps like an alarm clock or any other notifications which wakes up your phone, because the screen with the switch can accidentally touch a surface in your pocket and will get falsely engaged.

Question: Is it possible to disable the automatic sliding upon touching? I was hoping to find a slider switch where a user MUST slide (not touch), like when you answer your phone or snooze your alarm clock.
 
Top