Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android multiple image in order as background resource of a button

Tags:

android

I have a requirement in Android. I have a button. And i want to render 5 images one after another as the background resource of the button with a time difference.

It is like when the rendering starts, the first image will be shown. After few miliseconds, the second image will be shown and will continue until the 5th one is shown.

I think it is achievable with handler. But quite not sure how. Can someone please help

like image 433
Bhabani Shankar Avatar asked Jan 18 '26 20:01

Bhabani Shankar


1 Answers

Use a CountDownTimer:

//25 second, 5 second per image
new CountDownTimer(25000, 5000) {

     public void onTick(long millisUntilFinished) {
         //Set your image
     }

     public void onFinish() {
         //Done!
     }
}.start();

See here for more advice CoundDownTimer

like image 85
Michele Lacorte Avatar answered Jan 21 '26 09:01

Michele Lacorte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!