B4A Library MLStopWatch library

This is my implementation of the Android Chronometer. It includes more controls and it shows milliseconds. You will need to manually add it as shown in the included demo project.

Copy the MLStopWatch.jar and .xml files to your additional libraries directory and unzip the MLstopwatchdemo.zip to anywhere you want to use the demo project.

MLStopWatch
Author:
Jem Miller - Missing Link Software
Version: 1.01
  • MLStopWatch
    Methods:
    • BringToFront
    • GetTime As Long
      Implements a method that returns the current time, in milliseconds.
    • Initialize (EventName As String)
      Initializes the Stopwatch.
      No events are supported, so just pass ""
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • Lap
      Record a lap at the current elapsed time.
    • Pause
      Pause the stopwatch. Does nothing If the stopwatch is not running.
    • RemoveView
    • RequestFocus As Boolean
    • Reset
      Reset the stopwatch to the initial state This clears ALL stored lap times and sets the view to 00:00.00.
    • Resume
      Resumes the stopwatch.
    • 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)
    • SetTextColorAnimated (arg0 As Int, arg1 As Int)
    • SetTextSizeAnimated (arg0 As Int, arg1 As Float)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • Split As String
      Returns the split time between calls to Split for times between objects.
      Split pauses the stopwatch and displays the split time. The Split function is cancelled by a call to Resume, Stop or Reset.
      Returns the split time in a formatted string as Hours:Minutes:Seconds.milliseconds. Will return 00:00.00 on the first call and the split time offset on subsequent calls.
      This method also updates the stopwatch display with the current split time. Call Resume to display the running elapsed time again.
    • Start
      Starts the stopwatch (starts from 00:00.00).
    • Stop
      Stops the stopwatch.
    • isRunning As Boolean
      Returns True if the stopwatch is currently running or False otherwise.
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • ElapsedTime As Long [read only]
      Returns The amount of time recorded by the stopwatch, in milliseconds
    • Enabled As Boolean
    • Gravity As Int
    • Height As Int
    • Laps As List [read only]
      Returns A list of the lap times recorded. Each lap is given as a formatted string value from when the stopwatch began running.
      Example :
      00:03.12
      00:11.87
      00:26.41
    • Left As Int
    • Tag As Object
    • Text As String
    • TextColor As Int
    • TextSize As Float
    • Top As Int
    • Typeface As Typeface
    • Visible As Boolean
    • Width As Int


Version - 1.00 - Initial release

Version 1.01 = Added Split method

--

--- Jem
 

Attachments

  • MLStopWatch-1.01.zip
    13.7 KB · Views: 386
Last edited:

billyrudi

Active Member
Licensed User
Longtime User
hi your stopwatch shows also hour?
can i put two on the same activity?
regards Paolo
 

Bohica93

Member
Licensed User
Longtime User
Hi,

Is there anyway to get each lap time separately, not as a count from the start, but as a count from the last lap time?

Thanks.
 

HotShoe

Well-Known Member
Licensed User
Longtime User
can i put two on the same activity?

Yes you can.


Is there anyway to get each lap time separately, not as a count from the start, but as a count from the last lap time?

Like a split time? I think that can be done. I'll have a look at it over the weekend.

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Added a Split time method. See the modified demo project included in the zip file.

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
hi your stopwatch shows also hour?

Sorry, I missed this part of the question, yes it does show hours, minutes, seconds, and milliseconds.

--- Jem
 

jtare

Active Member
Licensed User
Longtime User
It is possible to only display seconds and milliseconds? (00.00) instead of (00:00.00)
Thanks
 
Top