Using this method i can set a delay in an action i want do:
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 5 seconds
}
}, 5000);
Is there a way to display the countdown of this 5 seconds in a toast? Thanks
If you mean that they stack up causing a delay then you should cancel the prior toast before showing a new one.
If you want something more fancy you could try using a PopupWindow instead to show the countdown, there you have more freedom for layout etc.
http://developer.android.com/reference/android/widget/PopupWindow.html
This is an answer by somebody else: https://stackoverflow.com/a/15174370/2767703
Example: