K
K
kovurado2022-02-04 16:56:26
Java
kovurado, 2022-02-04 16:56:26

How to make a dynamic change of photo and text by time of day?

How to make a dynamic change of picture and text, depending on the time of day on the fragment?
Simply put, if the time is from 6 am to 12 am, then one text and one picture are shown, by one o'clock in the afternoon, this picture and text change.
I do everything on Android Stuio.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2022-02-04
@xez

var currentHour = Instant.now().get(CLOCK_HOUR_OF_DAY);
        if (currentHour <= 12 && currentHour >= 6) {
          // показывается один текст и одна картинка
        } else {
           // эта картинка и текст изменяются.
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question