This is what I have so far.. it just starts when the application is opened:
package com.android.countdown;
import android.app.Activity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.widget.TextView;
public class countdown extends Activity {
TextView mTextField;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTextField = (TextView) findViewById(R.id.timer1);
new CountDownTimer(100000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("Seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("Finished");
}
}.start();
}
}
I know that I need to call start() inside a button procedure. However, if I move the .start() from where it’s at the new CountDownTimer(100000 , 1000) { gets an error.
Well… maybe you need to first understand how Java and programming work. Then, you can try to do something like this: