Code for Chronometer In Android :
ChronoMeter à To show time passing instead of incremental progress. Useful if it’s the user who is taking time doing some task or In a game where some action needs to be timed.
XML layout resource definition:
<Chronometer
android:id=”@+id/Chronometer01”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:format=”Timer: %s” />
Won’t show the passage of time until its start() method is called, stop() method is called to stop the timer.
setBase() is to count from a particular time in the past instead of from the time it’s started.
Handling the event
final Chronometer timer = (Chronometer)findViewById(R.id.Chronometer01);
timer.setBase(0);
timer.start();
Listen for changes to the Chronometer by implementing the Chronometer.OnChronometerTickListener interface.
Passing android.os.SystemClock.elapsedRealtime() in to the setBase() method starts the Chronometer control at 0.
timer.setBase(android.os.SystemClock.elapsedRealtime());
ChronoMeter à To show time passing instead of incremental progress. Useful if it’s the user who is taking time doing some task or In a game where some action needs to be timed.
XML layout resource definition:
<Chronometer
android:id=”@+id/Chronometer01”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:format=”Timer: %s” />
Won’t show the passage of time until its start() method is called, stop() method is called to stop the timer.
setBase() is to count from a particular time in the past instead of from the time it’s started.
Handling the event
final Chronometer timer = (Chronometer)findViewById(R.id.Chronometer01);
timer.setBase(0);
timer.start();
Listen for changes to the Chronometer by implementing the Chronometer.OnChronometerTickListener interface.
Passing android.os.SystemClock.elapsedRealtime() in to the setBase() method starts the Chronometer control at 0.
timer.setBase(android.os.SystemClock.elapsedRealtime());





0 comments:
Post a Comment