I would like to know which of these implementations is correct?
tlb.setVisibility(View.GONE);
or
tlb.setVisibility(false);
What's the difference between them?
I would like to know which of these implementations is correct?
tlb.setVisibility(View.GONE);
or
tlb.setVisibility(false);
What's the difference between them?
According to the documentation , the setVisibility
method requests a int
, and not a boolean
!
You can use three options:
View.INVISIBLE (Not displayed but takes up the space in screen)
View.GONE (Not displayed and does not take up space on screen)
I believe that if you try to pass a boolean
on this method, the following error should occur:
Error: no suitable method found for setVisibility (boolean) method View.setVisibility (int) is not applicable (argument mismatch; boolean can not be converted to int) method ImageView.setVisibility (int) is not applicable (argument mismatch; boolean can not be converted to int) method VisibilityAwareImageButton.setVisibility (int) is not applicable (argument mismatch; boolean can not be converted to int)
The property Gone
causes the view to be treated as if it did not exist while Invisible
is simply invisible, so it does have a difference.