0

Hello guys! I'm trying to create a countdown timer for a memory app. The user is given about 5-10 seconds to look at the gridview of pictures then the countdown timer starts. I was wondering how I can achieve this. The code below shows the countdown timer which starts at 30 seconds.

public class Play extends AppCompatActivity {

    TextView tvTimer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play);

        tvTimer = (TextView) findViewById(R.id.tv_timer);

        CountDownTimer timer = new CountDownTimer(30000, 1000) {

            public void onTick(long millisUntilFinished) {
                tvTimer.setText(" " + millisUntilFinished / 1000);
            }

            public void onFinish() {
                tvTimer.setText("done!");
            }
        }.start();

    }
2
Contributors
2
Replies
26
Views
2 Years
Discussion Span
Last Post by laguardian
0

My old solution was 2 timers not one. I fire the timer that will later start the second one. The first timer disables itself after it enabled the second timer.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.