0

the variable should get value false at hint 1 but when it checked in the if statement at hint 2 is still true enter image description here

  • don't expect us to visit external links, post all relevant information in your question – Stultuske Jun 21 '20 at 18:47
  • Please don't post screenshots of your code, or other textual content. Instead post the actual text, and use the formatting tools of Stack Overflow to mark it up. – Frank van Puffelen Jun 21 '20 at 20:01

1 Answers1

1

That's because set action and onClickListener is a nonsynchronous callback.

The code that actually sets the boolean value to false doesn't execute immediately. So when you get to the if statement the value still hasn't changed.

super-user
  • 74
  • 8