A
A
Alexey Medvedev2015-07-27 21:38:58
Java
Alexey Medvedev, 2015-07-27 21:38:58

How to correctly specify the condition for the "if" operator?

if (button1.VISIBLE && button2.VISIBLE) toast.makeText(...);

The environment swears at the condition - "Operator '&&' cannot be applied to 'int', 'int'"
Question: how to build the condition correctly? And is it possible to make it so?
I would google it without any problems if I knew how to construct the right question for the search query.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Emin, 2015-07-27
@RockBearLTD

It's simple, you are comparing two constants. Not only are they int, they are also constant. Such a condition will not give you anything. You need to check instead. View#getVisibility()
UPD: Final version:

if (button1.getVisibility() == View.VISIBLE && button2.getVisibility() == View.VISIBLE) {}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question