Android multiple images as button resource background

I have a requirement in Android. I have a button. And I want to make 5 images one by one as the background of a button resource with a time difference.

This is similar to the start of rendering, the first image will be shown. After a few milliseconds, the second image will be shown and will continue until the fifth is displayed.

I think this is possible with a handler. But I don’t know at all how to do it. Someone can help

+4
source share
1 answer

Use 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 CoundDownTimer for more details.

+5
source

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


All Articles