Hi all,
I'm new to B4A, as a starter i create simple customview of simple checkbox. The reason i need this checkbox is changing the box and mark color, here is the code:
My problem is:
1. How to fire event ValueChange with returning boolean value state
2. The layout is great with small dimension, but how to make it proportionally resize to bigger dimension
Thank you for your enlighment
I'm new to B4A, as a starter i create simple customview of simple checkbox. The reason i need this checkbox is changing the box and mark color, here is the code:
B4X:
'Custom View class
#Event: ValueChanged (Value As Boolean)
#DesignerProperty: Key: CheckBoxValue, DisplayName: Checked, FieldType: Boolean, DefaultValue: False, Description: CheckBox value.
#DesignerProperty: Key: CheckBoxDotColor, DisplayName: Dot Color, FieldType: Color, DefaultValue: 0xFFFF0000, Description: CheckBox dot color
Sub Class_Globals
Private mEventName As String 'ignore
Private mCallBack As Object 'ignore
Private mBase As Panel
Private Const DefaultColorConstant As Int = -984833 'ignore
Private dotPanel As Panel
Private isValue As Boolean
Private dotColor As ColorDrawable
End Sub
Public Sub Initialize (Callback As Object, EventName As String)
mEventName = EventName
mCallBack = Callback
End Sub
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
Dim clr As Int
mBase = Base
dotPanel.Initialize("Click")
isValue=Props.Get("CheckBoxValue")
If isValue = True Then
clr = Props.Get("CheckBoxDotColor")
Else
clr = Colors.White
End If
dotColor.Initialize(clr, 2)
dotPanel.Background = dotColor
mBase.AddView(dotPanel,4dip,4dip,mBase.Width-8dip, mBase.Height-8dip)
End Sub
Public Sub GetBase As Panel
Return mBase
End Sub
public Sub dotPanel_Click
CallSub(mCallBack, mEventName & "_" & "ValueChanged")
End Sub
Sub b4aCheckBox1_ValueChanged (Value As Boolean)
ToastMessageShow("CheckBox was clicked !",False)
End Sub
My problem is:
1. How to fire event ValueChange with returning boolean value state
2. The layout is great with small dimension, but how to make it proportionally resize to bigger dimension
Thank you for your enlighment