B4A Library [B4X] [XUI] AS Checkbox

This is a simple cross platform Checkbox.

If you need a checkbox with text, then check out the AS_CheckBoxAdvanced

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 or with a coffee. :)
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


AS_Checkbox
Author: Alexander Stolte
Version: 2.00
  • ASCheckbox
    • Events:
      • CheckedChange (Checked As Boolean)
    • Fields:
      • mBase As B4XView
      • Tag As Object
    • Functions:
      • Base_Resize (Width As Double, Height As Double)
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
        Base type must be Object
      • Initialize (Callback As Object, EventName As String)
      • SetIcon (icon As String, isfontawesome As Boolean)
    • Properties:
      • BorderCornerRadius As Int [write only]
      • BorderWidth As Int [write only]
      • Checked As Boolean
      • Checked2 As Boolean [write only]
        Without the CheckedChange Event
      • CheckedAnimated As Boolean [write only]
      • CheckedBackgroundColor As Int [write only]
      • DisabledBackgroundColor As Int
      • DisabledIconColor As Int
      • Enabled As Boolean
      • IconColor As Int
      • isEvent As Boolean
      • isFillUncheckedBackgroundColor As Boolean
      • isFontAswesome As Boolean
      • isHaptic As Boolean
      • isround As Boolean
      • Theme As AS_CheckBox_Theme [write only]
      • Theme_Dark As AS_CheckBox_Theme [read only]
      • Theme_Light As AS_CheckBox_Theme [read only]
      • UncheckedBackgroundColor As Int
      • UncheckedIconColor As Int
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+
  • 1.08
    • BugFix - When creating the view the CheckedChange event was triggered with parameter "False"
  • 1.09
    • Add Event property - If False then the CheckedChange event is not triggered
  • 1.10
    • Base_Resize is now public
  • 1.11
    • Intern Improvements
    • Add get and set IconColor
  • 1.12
    • Add set Checked2 - Without the CheckedChange Event
  • 2.00 (read more)
    • Add Designer Property FillUncheckedBackgroundColor
    • Add Designer Property UncheckedBackgroundColor
    • Add Designer Property UncheckedIconColor
    • Add Designer Property Round
      • Default: False
    • Add set Theme
    • Add get Theme_Dark
    • Add get Theme_Light
    • Add Designer Property ThemeChangeTransition
      • Default: None
Have Fun :)
 

Attachments

Last edited:
i testint and get this error:
B4A Versión: 10.0
Java Versión: 8
Parseando código. Error
Error al analizar el programa.
Descripción del error: Variable 'xuiviewsutils' no declarada se utiliza antes de que se le haya asignado cualquier valor.
Ha ocurrido un error en la línea: 184 (ASCheckbox)
If g_Haptic Then XUIViewsUtils.PerformHapticFeedback(mBase)

libraris used are: aschecbox (1.03), baxpages 1.05, core 9.9, stringutils 1.12, xui 2.0, xui vies 2.35
 
Helo, trying to catch the ASCheckbox in a CLV Panel with
Code:
For i=0 To CLV_Capex.Size-1
        CLV_Item_Pan = CLV_Capex.GetPanel(i)
        For Each v As B4XView In CLV_Item_Pan.GetAllViewsRecursive
            Try
                Dim Cbx As ASCheckbox
                Cbx.Initialize(Me, "Cbx_IsChecked")
                Cbx.mBase = v
                Log(v Is CheckBox)
                Log("CBX.Checked = " & Cbx.Checked)
            Catch
               
            End Try
           
           
            Log(v)
           
            'If v Is CheckBox Then
            'End If
           
        Next
       
        Log("Stop")
       
    Next

What kind is the view in order to catch it?
 
Helo, trying to catch the ASCheckbox in a CLV Panel with
Code:
For i=0 To CLV_Capex.Size-1
        CLV_Item_Pan = CLV_Capex.GetPanel(i)
        For Each v As B4XView In CLV_Item_Pan.GetAllViewsRecursive
            Try
                Dim Cbx As ASCheckbox
                Cbx.Initialize(Me, "Cbx_IsChecked")
                Cbx.mBase = v
                Log(v Is CheckBox)
                Log("CBX.Checked = " & Cbx.Checked)
            Catch
             
            End Try
         
         
            Log(v)
         
            'If v Is CheckBox Then
            'End If
         
        Next
     
        Log("Stop")
     
    Next

What kind is the view in order to catch it?
Try this

B4X:
For Each v As B4XView In CLV_Item_Pan.GetAllViewsRecursive
    If v.Tag Is ASCheckbox Then
        Dim Cbx As ASCheckbox = v.Tag
        Log("CBX.Checked = " & Cbx.Checked)
    End If
Next
 
Try this

B4X:
For Each v As B4XView In CLV_Item_Pan.GetAllViewsRecursive
    If v.Tag Is ASCheckbox Then
        Dim Cbx As ASCheckbox = v.Tag
        Log("CBX.Checked = " & Cbx.Checked)
    End If
Next
It worked!!!! Tks a lot...you are "The Angel" of the day


Look this to understand what happened.
 
Last edited:
Nice checkbox.
Unfortunately setting Checked = True after loading the layout results in the box filled with the checked colour but no white tick.
I'd love to use it but I need a tickbox that defaults to ticked.

Many thanks

Allan
 
Unfortunately setting Checked = True after loading the layout results in the box filled with the checked colour but no white tick.
I'd love to use it but I need a tickbox that defaults to ticked.
Everything works for me...
B4A? B4I? B4J? that would be important information.
 
Sorry B4i
The only alteration to your example is I added this
Code:
Private Sub B4XPage_Created (Root1 As B4XView)
    Dim v As View
    Root = Root1
    Root.LoadLayout("frm_main")
    ASCheckbox1.Checked = True
End Sub
 
Sorry B4i
The only alteration to your example is I added this
On B4I you need to wait for the Resize Event if you want to change something visual on B4XPage_Created sub.
B4X:
#If B4I
Wait For B4XPage_Resize (Width As Int, Height As Int)
#End If
ASCheckbox1.Checked = True
 
I loaded the library (B4J) and immediately got errors.

The errors:
1603913960233.png


I have loaded dependencies:
1603913992773.png
 
I've added XUI Views and I still get the errors.

1603925651669.png
 
Back
Top