danjpalmer
Lurker
The code I have so far is:
There is a red 'x' by this line:
I'm not sure what I am meant to do to rectify it. Quite new to this so any pointers would be great. The page this code is on loads but the timer doesn't start.
Code:
import android.app.Activity;
import android.os.Bundle;
import android.widget.Chronometer;
import android.widget.Chronometer.OnChronometerTickListener;
import android.widget.TextView;
import android.os.SystemClock;
public class Test extends Activity {
TextView textGoesHere;
long startTime;
long countUp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
Chronometer stopWatch = (Chronometer) findViewById(R.id.chrono);
startTime = SystemClock.elapsedRealtime();
textGoesHere = (TextView) findViewById(R.id.textGoesHere);
stopWatch.setOnChronometerTickListener(new OnChronometerTickListener(){
@Override
public void onChronometerTick(Chronometer arg0) {
countUp = (SystemClock.elapsedRealtime() - arg0.getBase()) / 1000;
String asText = (countUp / 60) + ":" + (countUp % 60);
textGoesHere.setText(asText);
}
});
stopWatch.start();
}
}
There is a red 'x' by this line:
Code:
textGoesHere = (TextView) findViewById(R.id.textGoesHere);
I'm not sure what I am meant to do to rectify it. Quite new to this so any pointers would be great. The page this code is on loads but the timer doesn't start.