Cara Membuat Countdown Timer di Android
<-- Variabel Global -->
TextView txtCount;
private CountDownTimer countDownTimer;
private final long interval = 1 * 1000;
private final long startTime = 11 * 1000;
<-- Di dalam onCreate -->
txtCount = (TextView) findViewById(R.id.textView1);
countDownTimer = new MyCountDownTimer(startTime, interval);
<-- Class baru di dalam class Main -->
public class MyCountDownTimer extends CountDownTimer {
public MyCountDownTimer(long startTime, long interval) {
super(startTime, interval);
}
@Override
public void onTick(long millisUntilFinished) {
txtCount.setText("" + millisUntilFinished / 1000);
}
@Override
public void onFinish() {
txtCount.setText("");
countDownTimer.cancel();
}}
Nah itulah tutorial Android tentang "Cara Membuat Countdown Timer di Android" yang bisa saya bagikan untuk sobat sakuning. Semoga artikel "android" ini bisa bermanfaat bagi sobat dalam mengerjakan tugas maupun pekerjaan coding sobat :). Sekian...
[caption id="attachment_783" align="aligncenter" width="300"] CountDown Timer Java on Android[/caption]
0 Response to "Cara Membuat Countdown Timer di Android"
Posting Komentar