How can create a View
like this
In the quiz game, each level, this View
will countdown the time, the faster the answer is chosen, the higher score will be. So, the first thing is how to get the time on this View
.
How can create a View
like this
In the quiz game, each level, this View
will countdown the time, the faster the answer is chosen, the higher score will be. So, the first thing is how to get the time on this View
.
Create a layout for your alarm drawable, including an ImageView and a TextView that overlays on it.
Initialize your objects before onCreate():
CountDownTimer countDownTimer;
TextView tvTime;
Then create a method and add this to it, or add it to onCreate():
countDownTimer = new CountDownTimer(60000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
tvTime.setText(String.valueOf((int) millisUntilFinished / 1000));
}
@Override
public void onFinish() {
endGame(); //End the game or do whatever you want.
}
}.start();
where 60000 is the total countdown time in milliseconds and 1000 is the time interval for onTick in milliseconds.