//generate a Chronometer in xml
<Chronometer android:id="@+id/chronometer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
></Chronometer>
//go to java code
//Create a object of Chronometer
Chronometer cm=(Chronometer)findViewById(R.id.chronometer);
//start the Chronometer
cm.start();
//above code will show you stop watch on your activity
//for stop
cm.stop();
//for restart time
<Chronometer android:id="@+id/chronometer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
></Chronometer>
//go to java code
//Create a object of Chronometer
Chronometer cm=(Chronometer)findViewById(R.id.chronometer);
//start the Chronometer
cm.start();
//above code will show you stop watch on your activity
//for stop
cm.stop();
//for restart time
cm.getBase(SystemClock.elapsedRealtime());
0 comments:
Post a Comment