A
A
ABU SADDAM SHISHANI2019-07-05 13:13:07
Java
ABU SADDAM SHISHANI, 2019-07-05 13:13:07

if check. How to make a loop in java?

There is an application code that changes the color of some text in a certain period of time

if ( hour == 9 || (hour == 10 && min <= 20) ) {
            txt.setTextColor(Color.GREEN);
        }

This condition is located in the @Override method
protected void onCreate(Bundle savedInstanceState)
The problem is that it checks the condition only when the application starts and you have to restart ... I tried to solve it using while but it didn’t work out.
- Kowalski, options...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cheypnow, 2019-07-05
@mutafakkir

With while, but in a separate thread, so as not to block the entire UI

R
Roman Prokopiev, 2019-07-05
@romik74

You can create a background service and start a timer there. At the end of the broadcast time, intercept the end of the timer and change the color

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question