I studied clocks and timers today.
I think AnalogClock and DigitalClock can use it directly. The only thing you need to know is that AnalogClock can modify the dial and minute hand.
Methods are Android:dail and Android:hand_minute and Hand_hour.
The use of timers is described below.
First, just put a chronometer and a button in the XML. In order to click the Start button, start the timer, 20s stop.
PackageCom.example.chronometer;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.os.SystemClock;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.widget.Button;ImportAndroid.widget.Chronometer;ImportAndroid.widget.Chronometer.OnChronometerTickListener; Public classMainactivityextendsActivity {chronometer ch; Button start; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); CH=(chronometer) Findviewbyid (r.id.test); Start=(Button) Findviewbyid (R.id.start); Start.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {//TODO auto-generated Method Stub//Set Start timing timech.setbase (Systemclock.elapsedrealtime ()); //Start TimerCh.start (); Start.setenabled (false); } }); Ch.setonchronometerticklistener (NewOnchronometerticklistener () {@Override Public voidOnchronometertick (chronometer chronometer) {//TODO auto-generated Method Stub//if it's more than 20s from timing to now, if(Systemclock.elapsedrealtime ()-ch.getbase () >20*1000) {ch.stop (); Start.setenabled (true); } } }); } }
In order to achieve this function, we should implement this function by monitoring the buttons and timers.
I think it's possible to change the function to create a edittext, enter the timekeeping time, and then stop the timer ...