Reputation: 23
According to android docs,
void setVisibility(int visibility)
has One the following parameters VISIBLE
, INVISIBLE
, or GONE
.
View dp2 = findViewByid(R.id.title);
dp2.setVisibility(View.GONE);
So why do we have to use View.GONE
, instead of dp2.setVisibility(GONE);
Upvotes: 0
Views: 4872
Reputation: 3313
if you are in a class that extends View or extends
any class that extends View
, then you can directly use GONE
without using View.GONE
, but if you are in a class that does not extend any View
then you have to use View.GONE
, that is because GONE
is a constant defined in the class View
Upvotes: 1
Reputation: 1006614
GONE
is a static
field on the View
class.
If your code has import android.view.View
, you reference GONE
as View.GONE
.
If your code has import static android.view.View.GONE
— a static import — you can reference GONE
simply as GONE
.
Upvotes: 2