Reputation: 73
I have checked the android docs for setVisibility()
. It shows that
setVisibility(int value)
So as far as I know it means that setVisibility()
accepts an integer value as input. But in one of the java codes, I found that it was written as
setVisibility(view.Visible)
This means it takes a view type as input. But how's that possible. I can't understand the logic behind this. Can anyone help in sort out this?
Upvotes: 2
Views: 1757
Reputation: 2366
There is int
argument of setVisibility()
method
public void setVisibility(int visibility) {
throw new RuntimeException("Stub!");
}
There is inbuilt int of this Gone , invisible etc...
public static final int GONE = 8;
public static final int INVISIBLE = 4;
public static final int VISIBLE = 0;
Upvotes: 2
Reputation: 967
Yes, it accept the integer value. But internally it have defined TypeDef of visibility options with values of VISIBLE, INVISIBLE and GONE. All three options have their int value defined internally (you don't have to worry about it).
So, whenever you pass View.Visible it takes the internal int value of that.
And one thing, it have defined TypeDef so you can pass value as integer same as they have internally, but you can't pass another values.
Those are the int value of that all options:
VISIBLE = 0x00000000
INVISIBLE = 0x00000004
GONE = 0x00000008
Upvotes: 3