B4A Library [B4X] [XUI] AS Radio Button

This is a simple cross platform RadioButton.

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
B4a: XUi,XUI Views
B4i: iXUI,XUI Views
In B4I the animation is limited, because otherwise the circle would look too angular in the animation.
Screenshot_20200904-230850.jpg
ezgif.com-crop.gif
Screenshot_20201127-111648.jpg

Animation = NONE (default)
animation none.gif

ASCheckbox
Author: Alexander Stolte
Version: 1.04

  • ASRadioButton
    • Events:
      • CheckedChange (Checked As Boolean)
    • Fields:
      • g_Haptic As Boolean
      • 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
      • getBase As B4XView
      • getChecked As Boolean
      • getDisabledCheckedBackgroundColor As Int
      • getDisabledUncheckedBackgroundColor As Int
      • getEnabled As Boolean
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Tests whether the object has been initialized.
      • setBorderWidth (width As Int) As String
      • setChecked (b_checked As Boolean) As String
      • setCheckedBackgroundColor (crl As Int) As String
      • setDisabledCheckedBackgroundColor (crl As Int) As String
      • setDisabledUncheckedBackgroundColor (crl As Int) As String
      • setEnabled (enable As Boolean) As String
      • setUncheckedBackgroundColor (crl As Int) As String
    • Properties:
      • Base As B4XView [read only]
      • BorderWidth
      • Checked As Boolean
      • CheckedBackgroundColor
      • DisabledCheckedBackgroundColor As Int
      • DisabledUncheckedBackgroundColor As Int
      • Enabled As Boolean
      • UncheckedBackgroundColor
Changelog
  • 1.00
    • Release
  • 1.01
  • 1.02
    • Add DisabledCheckedBackgroundColor property and designer property
    • Add DisabledUnCheckedBackgroundColor property and designer property
      • Screenshot_20201127-111648.jpg
    • Add Enable property - enable or disable the view
    • BugFixes
  • 1.03
    • Add Designer Property Animation -Select-Animation NONE=without Slide=the normal animation
      • animation none.gif
  • V1.04
    • BugFix - Enabled = False, now the view is disabled, no touch gestures allowed
  • V1.05
    • Base_Resize is now public
Have Fun :)
 

Attachments

  • AS RadioButton Example.zip
    178.3 KB · Views: 723
  • ASRadioButton.b4xlib
    2.8 KB · Views: 445
Last edited:

angel_

Well-Known Member
Licensed User
Longtime User
It looks really cool, it would be nice to have the Enable property
 

wimpie3

Well-Known Member
Licensed User
Longtime User
If I'm right, we have to add the text next to the radio button ourselves? The "text" property is not supported? This means that we also need to calculate the y-offsets for multiline labels, like in this example? (same question for AS Checkbox)

1651136717068.png
 

wimpie3

Well-Known Member
Licensed User
Longtime User
These properties don't seem to be correct or sufficient?
B4X:
    Dim m_Properties As Map
    m_Properties.Initialize
    m_Properties.Put("Animation",0)
    m_Properties.Put("CheckedBackgroundColor",0xFF2D8879)
    m_Properties.Put("UnCheckedBackgroundColor",0xFFFFFFFF)
    m_Properties.Put("DisabledCheckedBackgroundColor",0x98FFFFFF)
    m_Properties.Put("DisabledUncheckedBackgroundColor",0x98FFFFFF)
    m_Properties.Put("BorderWidth",2)
    m_Properties.Put("HapticFeedback",False)

Is there a way to find out exactly what properties have to be added?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Is there a way to find out exactly what properties have to be added?
a "DesignerProperty" have a FieldType e.g. String and a DefaultValue e.g. NONE.
you can see which data type is required and what its default value is.

m_Properties.Put("Animation",0)
wrong. In the source code is the following:
B4X:
#DesignerProperty: Key: Animation, DisplayName: Animation, FieldType: String, DefaultValue: NONE, List: NONE|Slide
FieldType = String
Value = "NONE"
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Hmmm... I seem to do something terribly wrong, cause I don't see the radio button appearing (I only see the cyan background of the panel):
B4X:
    Dim m_Properties As Map
    m_Properties.Initialize
    m_Properties.Put("Animation","NONE")
    m_Properties.Put("CheckedBackgroundColor",0xFF2D8879)
    m_Properties.Put("UnCheckedBackgroundColor",0xFFFFFFFF)
    m_Properties.Put("DisabledCheckedBackgroundColor",0x98FFFFFF)
    m_Properties.Put("DisabledUnCheckedBackgroundColor",0x98FFFFFF)
    m_Properties.Put("BorderWidth",2)
    m_Properties.Put("HapticFeedback",False)
   
    Dim xpnl_RadioButton As B4XView = xui.CreatePanel("")
    xpnl_RadioButton.Color=Colors.cyan
    Root.AddView(xpnl_RadioButton,0,0,300dip,50dip)
    
    Dim rb1 As ASRadioButton
    rb1.Initialize(Me,"rb1")
    Dim tmplbl As Label
    tmplbl.Initialize("")
    rb1.DesignerCreateView(xpnl_RadioButton,tmplbl,m_Properties)
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Square dimensions is not what's causing the problem, the radio button doesn't show up with 50dip x 50dip either.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Square dimensions is not what's causing the problem, the radio button doesn't show up with 50dip x 50dip either.
B4X:
    rb1.DesignerCreateView(xpnl_RadioButton,tmplbl,m_Properties)
    rb1.Base_Resize(50dip,50dip)

Update
  • V1.05
    • Base_Resize is now public
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Thanks for helping me out, but it's not (yet) working. I have to click on the panel to show the radio button. Strange.

PS I suspect AS_Checkbox needs it's Base_Resize to be made public as well?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Thanks for helping me out, but it's not (yet) working. I have to click on the panel to show the radio button. Strange.
I took the Example Project, took your code and after calling Base_Resize, the radio button appeared on the panel.

PS I suspect AS_Checkbox needs it's Base_Resize to be made public as well?
I think so
 
Top