A warp for this Github Project. I hope I have the code right in the B4A sample project....running a real time clock with the tab digits.
Note the files in the /Objects/res/values folder of the B4A project. Make sure they are set to READ ONLY before you run the B4A project
Library:
TabDigit
Author: Github: Xenione, Wrapped by: Johan Schoeman
Version: 1
Sample Code:
Note the files in the /Objects/res/values folder of the B4A project. Make sure they are set to READ ONLY before you run the B4A project
Library:
TabDigit
Author: Github: Xenione, Wrapped by: Johan Schoeman
Version: 1
- TabDigit
Fields:- ba As BA
- 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)
- elapsedTime (elapsedTime As Float)
- start
- Background As Drawable
- BackgroundColor As Int [write only]
- Char As Int [write only]
- Chars() As Char [write only]
Sets chars that are going to be displayed.
Note: <b>That only one digit is allow per character.</b> - Color As Int [write only]
- CornerSize As Int [write only]
- DividerColor As Int [write only]
- Enabled As Boolean
- Height As Int
- Left As Int
- Padding As Int [write only]
- Parent As Object [read only]
- Tag As Object
- TextColor As Int [write only]
- TextSize As Int [write only]
- Top As Int
- Visible As Boolean
- Width As Int
Sample Code:
B4X:
#Region Project Attributes
#ApplicationLabel: b4aTabDigit
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim t As Timer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private tdsec1 As TabDigit
Private tdsec10 As TabDigit
Private tdmin1 As TabDigit
Private tdmin10 As TabDigit
Private tdhr1 As TabDigit
Private tdhr10 As TabDigit
Dim prevsec1 As Int
Dim prevsec10 As Int
Dim prevmin1 As Int
Dim prevmin10 As Int
Dim prevhr1 As Int
Dim prevhr10 As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
t.Initialize("t", 10)
tdsec1.Chars = Array As Char("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
tdsec10.Chars = Array As Char("0", "1", "2", "3", "4", "5")
tdmin1.Chars = Array As Char("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
tdmin10.Chars = Array As Char("0", "1", "2", "3", "4", "5")
tdhr1.Chars = Array As Char("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
tdhr10.Chars = Array As Char("0", "1", "2")
Dim hour As Int = DateTime.GetHour(DateTime.Now)
Dim minute As Int = DateTime.GetMinute(DateTime.Now)
Dim second As Int = DateTime.GetSecond(DateTime.Now)
tdsec1.Char = second Mod 10
tdsec10.Char = second - (second Mod 10)
tdsec1.TextSize = 250
tdsec1.DividerColor = Colors.Red
tdsec1.Padding = 20
tdsec1.TextColor = Colors.Cyan
tdsec1.BackgroundColor = Colors.Gray
prevsec1 = second Mod 10
tdsec10.Char = (second - (second Mod 10))/10
tdsec10.TextSize = 250
tdsec10.DividerColor = Colors.Red
tdsec10.Padding = 20
tdsec10.TextColor = Colors.Cyan
tdsec10.BackgroundColor = Colors.Gray
prevsec10 = (second - (second Mod 10))/10
tdmin1.Char = minute Mod 10
tdmin10.Char = minute - (minute Mod 10)
tdmin1.TextSize = 250
tdmin1.DividerColor = Colors.Red
tdmin1.Padding = 20
tdmin1.TextColor = Colors.Blue
tdmin1.BackgroundColor = Colors.white
prevmin1 = minute Mod 10
tdmin10.Char = (minute - (minute Mod 10))/10
tdmin10.TextSize = 250
tdmin10.DividerColor = Colors.Red
tdmin10.Padding = 20
tdmin10.TextColor = Colors.Blue
tdmin10.BackgroundColor = Colors.white
prevmin10 = (minute - (minute Mod 10))/10
tdhr1.Char = hour Mod 10
tdhr10.Char = hour - (hour Mod 10)
tdhr1.TextSize = 250
tdhr1.DividerColor = Colors.Red
tdhr1.Padding = 20
tdhr1.TextColor = Colors.Yellow
tdhr1.BackgroundColor = Colors.LightGray
prevhr1 = hour Mod 10
tdhr10.Char = (hour - (hour Mod 10))/10
tdhr10.TextSize = 250
tdhr10.DividerColor = Colors.Red
tdhr10.Padding = 20
tdhr10.TextColor = Colors.Yellow
tdhr10.BackgroundColor = Colors.LightGray
prevhr10 = (hour - (hour Mod 10))/10
End Sub
Sub Activity_Resume
t.Enabled = True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
t.Enabled = False
End Sub
Sub t_tick
Dim hour As Int = DateTime.GetHour(DateTime.Now)
Dim minute As Int = DateTime.GetMinute(DateTime.Now)
Dim second As Int = DateTime.GetSecond(DateTime.Now)
If prevsec1 <> second Mod 10 Then
tdsec1.start
prevsec1 = second Mod 10
End If
If prevsec10 <> (second - (second Mod 10))/10 Then
tdsec10.start
prevsec10 = (second - (second Mod 10))/10
End If
If prevmin1 <> minute Mod 10 Then
tdmin1.start
prevmin1 = minute Mod 10
End If
If prevmin10 <> (minute - (minute Mod 10))/10 Then
tdmin10.start
prevmin10 = (minute - (minute Mod 10))/10
End If
If prevhr1 <> hour Mod 10 Then
tdhr1.start
prevhr1 = hour Mod 10
End If
If prevhr10 <> (hour - (hour Mod 10))/10 Then
tdhr10.start
prevhr10 = (hour - (hour Mod 10))/10
End If
End Sub