Why does IDEA mark this Android code as erronous? It compiles

This is fine:

This is not:


What gives? Both are perfectly valid integers! If I wanted type checking, I'd use an enums (or rather - Google should have, but that's another discussion). Who is checking this? IDEA? Lint? Any way I can configure it to ignore these errors?

PS: If you wonder why I'd use inline constants instead of the defined constants: I don't. But using this method causes the same IDE-error:


public static int booleanToVisibleOrGone(boolean visible) {
    return visible ? View.VISIBLE :  View.GONE;



Comment actions Permalink

It is checked by lint inspection "Constant and Resource Type Mismatches". Press Alt+Enter and you'll see it. There you're also able to suppress checking or even completely disable the inspection.

Comment actions Permalink

Ah, thanks, that fixed it :-)


Please sign in to leave a comment.