Android Java countdown and then do somethign [closed]
How can i countdown to like 5 then something will happen?
Ex: Activity Starts it counts down to 5 then a toast comes up
This you can perform by using CountdownTimer in-build abstract class
new CountdownTimer(5000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
// Now countdown is finished, perform whatever you want
mTextField.setText("done!");
}
}.start();
Please use Timer class
See this link for reference
http://developer.android.com/resources/articles/timed-ui-updates.html
精彩评论