Im really getting lost using the whole CountDownTimer my aim is too simply restart the timer when the user presses a button, but near the onClick method it displays a warning saying “The method onClick from the type CountDownTimer is never used locally. If anyone realises where im going wrong guide me please! 🙂
Counter = new CountDownTimer(20000, 1000) {
public void onTick(long millisUntilFinished) {
TextView timeShow = (TextView)findViewById(R.id.time);
timeShow.setText(" "+" 00:" +millisUntilFinished / 1000);
}
public void onClick(View v) {
switch(v.getId()){
case R.id.keypad_0:
if(Counter !=null){
Counter.cancel();
}
}
};
@Override
public void onFinish() {
// TODO Auto-generated method stub
}
}.start();
The problem is that the CountDownTimer doesn’t actually have an onClick event.
You will want to put that onClick event handler in your Activity. (I am assuming you have a Button in your Activity layout XML that has an onClick attribute)
Also, I would change your Count variable into lowercase, because as it stands right now it looks like a Class.