English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.Chronometer

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.widget.TextView
android.widget.Chronometer

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

XML Attributes

Attribute name Related methods  
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. 
XML Attributes inherited from class android.widget.TextView
XML Attributes inherited from class android.view.View
Constants inherited from class android.view.View
Fields inherited from class android.view.View

Public Constructors

          Chronometer(Context context)
Initialize this Chronometer object.
          Chronometer(Context context, AttributeSet attrs, Map inflateParams)
Initialize with standard view layout information.
          Chronometer(Context context, AttributeSet attrs, Map inflateParams, 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).
        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  start()
Start counting up.
        void  stop()
Stop counting up.
Methods inherited from class android.widget.TextView