B4A Library [B4X] [XUI] AS Checkbox

This is a simple cross platform Checkbox.

I spend a lot of time in creating views, like this and to create a high quality view cost a lot of time. If you want to support me and further views, then you can do it here by Paypal. :)
B4j: jXUI,JavaObject
B4a: XUi,StringUtils,XUI Views (2.40+)
B4i: iXUI,XUI Views (2.40+)

Screenshot_20200903-003723.jpg
Screenshot_20200903-003753.jpg
ezgif.com-crop.gif

2020-09-03-10-17-41.gif
20-09-03-10-24-58.gif

Disabled style:
Screenshot_20201127-101856.jpg


ASCheckbox
Author: Alexander Stolte
Version: 1.07

  • ASCheckbox
    • Events:
      • CheckedChange (Checked As Boolean)
    • Fields:
      • mBase As B4XView
      • Tag As Object
    • Functions:
      • Class_Globals As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • setBorderCornerRadius (radius As Int) As String
      • setBorderWidth (width As Int) As String
      • setChecked (b_checked As Boolean) As String
      • setCheckedBackgroundColor (crl As Int) As String
      • SetIcon (icon As String, isfontawesome As Boolean) As String
    • Properties:
      • BorderCornerRadius
      • BorderWidth
      • Checked
      • CheckedBackgroundColor
Changelog
  • 1.00
    • Release
  • 1.01
    • Add CheckedAnimated
    • B4J BugFix Label Size was resizing if the font was to big
  • 1.02
    • Add HapticFeedback
  • 1.03
    • Checked was readonly
  • 1.04
    • Add DisabledBackgroundColor property and designer property
    • Add DisabledIconColor property and designer property
    • Add Enable property - enable or disable the view
      • Screenshot_20201127-101856.jpg
    • no animation if you change the checked state via code
  • 1.05
    • B4I No Jump animation if the BorderCornerRadius > 0 (the radius cannot be held during animation, so it looks buggy when you have e.g. a circle)
    • BugFix - Enabled = False, now the view is disabled, no touch gestures allowed
  • 1.06
    • Intern Function IIF renamed to iif2
  • 1.07
    • Add DesingerProperty Checked - if true then the checkbox is checked
    • Add DesingerProperty Enabled - if false then the checkbox is disabled
      • On B4A and B4J the core enabled property in the designer is not used anymore
    • BugFixes
    • Intern Function iif2 removed and the core iif is now used
      • B4A V11+ - B4J V9.10+ - B4I V7.50+
Have Fun :)
 

Attachments

  • AS Checkbox Example.zip
    177.7 KB · Views: 227
  • ASCheckbox.b4xlib
    3.2 KB · Views: 98
Last edited:

Alexander Stolte

Expert
Licensed User
Update
  • 1.04
    • Add DisabledBackgroundColor property and designer property
    • Add DisabledIconColor property and designer property
    • Add Enable property - enable or disable the view
      • Screenshot_20201127-101856.jpg
  • no animation if you change the checked state via code
Tip: if you uncheck the view "Enable" Property in the designer then the view is disabled
 

red30

Active Member
Licensed User
When I add text in designer, it doesn't show up in ASCheckbox. Why? Is it possible to somehow add text after the "checkmark"?
I cannot get the index when ASCheckbox is in CustomListView.
B4X:
Sub ASCheckBox1_CheckedChange(Checked As Boolean)
    Dim index As Int = allclv.GetItemFromView(Sender)
    Log(index)
End Sub
I get an error:
B4X:
mod4_ascheckbox1_checkedchange (java line: 609)
java.lang.ClassCastException: red.123.ascheckbox cannot be cast to android.view.View
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:89)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getParent(B4XViewWrapper.java:186)
    at b4a.example3.customlistview._getitemfromview(customlistview.java:413)
    at red.ap.expert.bestapp.mod4._checkbox11_checkedchange(mod4.java:609)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
    at red.ap.expert.bestapp.ascheckbox._checkedchange(ascheckbox.java:298)
    at red.ap.expert.bestapp.ascheckbox$ResumableSub_Check.resume(ascheckbox.java:285)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1704)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6865)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:504)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
How can I get the index?
 

Alexander Stolte

Expert
Licensed User
When I add text in designer, it doesn't show up in ASCheckbox. Why?
Because the view is only the checkbox, not checkbox + text.
Add a simple label after the checkbox and done.

Sub ASCheckBox1_CheckedChange(Checked As Boolean) Dim index As Int = allclv.GetItemFromView(Sender) Log(index) End Sub
i dont know what this code does, but it should be this:
B4X:
Sub ASCheckBox1_CheckedChange(Checked As Boolean)
    Dim tmp_checkbox As ASCheckBox = Sender
    Dim index As Int = allclv.GetItemFromView(tmp_checkbox.mBase)
    Log(index)
End Sub
 

Alexander Stolte

Expert
Licensed User
Update
  • 1.05
    • B4I No Jump animation if the BorderCornerRadius > 0 (the radius cannot be held during animation, so it looks buggy when you have e.g. a circle)
    • BugFix - Enabled = False, now the view is disabled, no touch gestures allowed
 

Alexander Stolte

Expert
Licensed User
Update
  • 1.07
    • Add DesingerProperty Checked - if true then the checkbox is checked
    • Add DesingerProperty Enabled - if false then the checkbox is disabled
      • On B4A and B4J the core enabled property in the designer is not used anymore
    • BugFixes
    • Intern Function iif2 removed and the core iif is now used
      • B4A V11+ - B4J V9.10+ - B4I V7.50+
 
Last edited:

ShaneG30

Well-Known Member
Licensed User
Intern Function iif2 removed and the core iif is now used
  • B4A V9.10+ - B4J V9.10+ - B4I V7.50+

IIf was introduced with B4A 11.0. (Also B4A 9.10 doesn't exist.)
 
Top