Possible Duplicate:
CountDownTimer- that the user increments. Issues
I have to make an application that allows the user to increment the time by +1, for every click of the button. Then after the button stops being clicked it waits for three seconds, then starts to countdown.
I've been pretty stuck then realized I might be able to implement this through a java action listener where I use something like this. I posted my code, this however doesn't work correctly - was just wondering if someone could lead me in the right direction.
Thank you
@SuppressWarnings("unused")
public class MainActivity extends Activity {
private static String TAG = "cs313f12p1a";
Button stoptime;
public TextView timedisplay;
public myTimer wavetimer;
private long millisInFuture;
private long millisUntilFinished;
private long countDownInterval;
private long onclicktime;
private WaveInterface model;
public long counter;
private boolean buttonClicked;
private Thread thread;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
stoptime = (Button) findViewById(R.id.button2);
stoptime.setText("Stop Timer");
timedisplay = (TextView) findViewById(R.id.mycounter);
timedisplay.setText("Time Left: " + millisUntilFinished);
wavetimer = new myTimer (millisInFuture, countDownInterval);
counter = 01;
final MainActivity MainActivity = this;
stoptime.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
if (!buttonClicked){
counter++;
} else {
wavetimer.start();
}
}
}});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}