B4A Library DigitSpeedView

A wrap for this Github project.

Extract LibRes.zip and then copy the folder with its contents to be on the same folder level as that of the B4A project's /Objects and /Files folders.

1.png


Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aDigitSpeedView
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\LibRes

#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 dsv1 As DigitSpeedView
    Private dsv2 As DigitSpeedView
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", 1000)
   
    dsv1.SpeedTextColor = Colors.Yellow
    dsv1.UnitTextColor = Colors.White
    dsv1.SpeedViewBackgroundColor = Colors.ARGB(100, 0, 0, 96)
    dsv1.SpeedUnit = "MPH"
    dsv1.SpeedTextSize = 35
    dsv1.UnitTextSize = 15
    dsv1.DisplayBackgroundImage = False
   
    dsv2.SpeedTextColor = Colors.Yellow
    dsv2.UnitTextColor = Colors.Green
'    dsv2.SpeedViewBackgroundColor = Colors.Black
    dsv2.SpeedUnit = "km/h"
    dsv2.SpeedTextSize = 60
    dsv2.UnitTextSize = 15
    dsv2.DisplayBackgroundImage = True   
    dsv2.SpeedShadowSize = 40
    dsv2.UnitShadowSize = 40
    dsv2.UnitShadowColor = Colors.Yellow
    dsv2.SpeedShadowColor = Colors.Red
   

End Sub

Sub Activity_Resume
   
    t.Enabled = True

End Sub

Sub Activity_Pause (UserClosed As Boolean)
   
    t.Enabled = False

End Sub

Sub t_tick
   
    dsv1.updateSpeed(Rnd(0,201))
    dsv2.updateSpeed(Rnd(0,1000))
   
End Sub


Sub dsv1_speed_changed(speed As Int)
   
    Log("B4A Speed 1 = " & speed)
   
End Sub

Sub dsv2_speed_changed(speed As Int)
   
    Log("B4A Speed 2 = " & speed)
   
End Sub

Library:
DigitSpeedView
Author:
Github: Riccardo Capuani, Wrapped by: Johan Schoeman
Version: 1
  • DigitSpeedView
    Events:
    • speed_changed (speed As Int)
    Fields:
    • ba As BA
    Methods:
    • 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)
    • hideUnit
      Hide unit text
    • showUnit
      Show unit text
    • updateSpeed (speed As Int)
      update speed
      speed: to update
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • DisplayBackgroundImage As Boolean [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • SpeedShadowColor As Int [write only]
    • SpeedShadowSize As Int [write only]
    • SpeedTextColor As Int [write only]
    • SpeedTextSize As Float [write only]
    • SpeedUnit As String [write only]
    • SpeedViewBackgroundColor As Int [write only]
    • Tag As Object
    • Top As Int
    • UnitShadowColor As Int [write only]
    • UnitShadowSize As Int [write only]
    • UnitTextColor As Int [write only]
    • UnitTextSize As Float [write only]
    • Visible As Boolean
    • Width As Int
 

Attachments

  • LibRes.zip
    2.9 KB · Views: 431
  • b4aDigitSpeedView.zip
    8.1 KB · Views: 403
  • DigitSpeedViewLibFiles.zip
    11 KB · Views: 409

aidymp

Well-Known Member
Licensed User
Longtime User
Is there a font file?

Caused by: java.lang.RuntimeException: Font asset not found fonts/digital-7_mono.ttf

I downloaded and copied a file with that name to Files/fonts the demo compiles but without any logs (from an emulator) says "unfortunately, digit has stopped!" no other error!?

Thanks

Aidy
 

Johan Schoeman

Expert
Licensed User
Longtime User

Attachments

  • digital-7.zip
    20.2 KB · Views: 360

aidymp

Well-Known Member
Licensed User
Longtime User
Attached is the 2 .ttf files. Make a folder called fonts inside the /Files folder of your B4A project and then copy the attached 2 files to be inside the fonts folder

tried with your files, that where the same as my files, in the same location and same result! no log output (on my emulator) runs, then message "Unfortunately, b4aDigitSpeedView has stopped!"
 

Johan Schoeman

Expert
Licensed User
Longtime User
tried with your files, that where the same as my files, in the same location and same result! no log output (on my emulator) runs, then message "Unfortunately, b4aDigitSpeedView has stopped!"
Try and run with only of the two indicators on the emulator and see if it runs (i.e juts try with dsv1 and comment out everything related to dsv2)
 

aidymp

Well-Known Member
Licensed User
Longtime User
Try and run with only of the two indicators on the emulator and see if it runs (i.e juts try with dsv1 and comment out everything related to dsv2)

That works, but i wanted 3 of them, Im now using a gauge "Velocimeter"from donmanfred, but that now seems to have issues!

Thanks

Aidy
 
Top