public class

Chronometer

extends TextView
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.Chronometer

Class Overview

Class that implements a simple timer.

You can give it a start time in the elapsedRealtime() timebase, and it counts up from that, or if you don't give it a base time, it will use the time at which you call start(). By default it will display the current timer value in the form "MM:SS" or "H:MM:SS", or you can use setFormat(String) to format the timer value into an arbitrary string.

Summary

Nested Classes
interface Chronometer.OnChronometerTickListener A callback that notifies when the chronometer has incremented on its own. 
XML Attributes
Attribute Name Related Method Description
android:format Format string: if specified, the Chronometer will display this string, with the first "%s" replaced by the current timer value in "MM:SS" or "H:MM:SS" form. 
[Expand]
Inherited XML Attributes
From class android.widget.TextView
From class android.view.View
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
Chronometer(Context context)
Initialize this Chronometer object.
Chronometer(Context context, AttributeSet attrs)
Initialize with standard view layout information.
Chronometer(Context context, AttributeSet attrs, int defStyle)
Initialize with standard view layout information and style.
Public Methods
long getBase()
Return the base time as set through setBase(long).
String getFormat()
Returns the current format string as set through setFormat(String).
Chronometer.OnChronometerTickListener getOnChronometerTickListener()
void setBase(long base)
Set the time that the count-up timer is in reference to.
void setFormat(String format)
Sets the format string used for display.
void setOnChronometerTickListener(Chronometer.OnChronometerTickListener listener)
Sets the listener to be called when the chronometer changes.
void start()
Start counting up.
void stop()
Stop counting up.
Protected Methods
void onDetachedFromWindow()
This is called when the view is detached from a window.
void onWindowVisibilityChanged(int visibility)
Called when the window containing has change its visibility (between GONE, INVISIBLE, and VISIBLE).
[Expand]
Inherited Methods
From class android.widget.TextView
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewTreeObserver.OnPreDrawListener