Thursday, December 9, 2010

Android and common sense

There is no questions one should not use raw numbers and strings in the code, as it will surely backfire. Usually,  old-style (C) common sense and int/bool logic is used even for defines,  but you may be surprised to find out that when you use View.setVisibility(int state) in Android :



public static final int INVISIBLE

Since: API Level 1
This view is invisible, but it still takes up space for layout purposes. Use with setVisibility(int).
Constant Value: 4 (0x00000004)

public static final int VISIBLE

Since: API Level 1
This view is visible. Use with setVisibility(int).
Constant Value: 0 (0x00000000)

So, use defines, Luke :-)