参考文章:http://stackoverflow.com/questions/7889754/android-resource-ids-suddenly-not-final-fields-cannot-be-resolved
有一个人回答是这样的:
+1 If the "Is Library" property is ticked, the R file generated declares identifiers as "public static int" rather than "public static final int" - hence the error message. Presumably this is something to do with making identifiers externally visible rather than allowing them to be optimized away by the compiler. – MZB Mar 7 at 18:57
大概意思是说如果项目勾选了Is Library,R文件生成的字段会变成public static int,而不是public static final int,所以才会出现上面的错误。解决方法去掉Is Library选项,然后clean项目。如果项目是Library项目,那只能按照提示把switch-case换成if-else了。
以上