I have a styles called Red and Green and I have an if statment to find out which to apply, but I don\'t know the code to actually apply a style from the java.
You can use the brand new Paris library to apply styles programmatically:
Paris.style(yourView).apply(condition ? R.style.Green : R.style.Red);
The only caveat is that not all attributes are supported (but many are and support can be added fairly easily by contributing to the library).
Disclaimer: I'm the original author of the library.