B4A Library StopWatch

A wrap for this Github project. Download and extract attached DemoRes.zip as well as resource.zip and then copy folder DemoRes and folder resource to be on the same folder level as that of the /Files and /Objects folders of the attached B4A folder.

It will raise and event in the B4A project with the lap numbers and the lap times.

1.gif


Sample Code:

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

#AdditionalRes: ..\resource
#AdditionalRes: ..\DemoRes


'#AdditionalRes: C:\Users\----------2\Documents\Basic 4 Android\JOHAN APPS\JHS LIBS\resource\b4a_appcompat, de.amberhome.objects.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\google\google-play-services\libproject\google-play-services_lib\res, com.google.android.gms
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design

'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama

'#Extends: android.support.v7.app.AppCompatActivity

#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.
   
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 Button1 As Button
    Dim sw As StopWatch
   
   
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")
    sw.Initialize("sw")
   
    sw.StopWatchTextColor = Colors.Blue
    sw.StopWatchTextSize = 40
   
End Sub

Sub Activity_Resume
   

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click


    sw.StartStopWatch

End Sub

Sub sw_lap_time(lapcounter As Int, laptime As String)
   
    Log("Lap Counter = " & lapcounter & " LapTime = " & laptime)
   
End Sub

Library:
StopWatch
Author:
Github: Dimcho Karpachev, Wrapped by: Johan Schoeman
Version: 1
  • StopWatch
    Events:
    • lap_time (lapcounter As Int, laptime As String)
    Methods:
    • Initialize (paramString As String)
    • IsInitialized As Boolean
    • StartStopWatch
    Properties:
    • StopWatchTextColor As Int [write only]
    • StopWatchTextSize As Int [write only]

Take note of the B4A manifest files
You need to enable AppCompat V3.20 in the libs tab of the B4A project (and maybe DesignSupport V2.00)
 

Attachments

  • b4aStopWatch.zip
    8.6 KB · Views: 483
  • DemoRes.zip
    395.1 KB · Views: 446
  • StopWatchLibFiles.zip
    11.2 KB · Views: 500
  • resource.zip
    423 bytes · Views: 449
Top