Display countdown timer in warning dialog

How to display a countdown timer in my warning window. I want to notify the user that the session will end in 5 minutes and will show the timer running in the warning popup.

+6
source share
2 answers

for the popup should be alertDialog :

 alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Alert 3"); alertDialog.setMessage("00:10"); alertDialog.show(); // new CountDownTimer(10000, 1000) { @Override public void onTick(long millisUntilFinished) { alertDialog.setMessage("00:"+ (millisUntilFinished/1000)); } @Override public void onFinish() { info.setVisibility(View.GONE); } }.start(); 
+22
source

Place the TextView in the dialog layout. Then, using the Handler.postDelayed () method (or CountDownTimer, or Timer, or [...]), update the value displayed in the TextView.

0
source

Source: https://habr.com/ru/post/916819/


All Articles