This is how it looks currently:
final CountDownTimer countdown = new CountDownTimer(5000, 1000) {
public void onTick(long millisUntilFinished) {
clock.setText("Seconds Remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
qcount++;
if (qcount < 10)
{
this.start();
switch (diff) {
case 0: //Novice difficulty
but it says the countdown variable isn’t used and it doesn’t run at all in the app.
You’re trying to use Countdown in the anonymous class that’ll instantiate it. Countdown is an instance of that class, onFinish() is called on that instance.
You should call start() on the instance onFinish() was called on, so use ‘this’.
EDIT : Look at it as if you were simply creating a new class, which is basically what you’re doing. In the new class definition, “Countdown” is not a variable, so you can’t use it. You’d simply call start on the object onFinish() was called on. However since you’re using an anonymous class, you can still access your outer class’s variables from within your anonymous class, which in this case leads to confusion and error.