android出现问题As of ADT 14, resource fields cannot be used as switch cases.

参考文章: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了。

以上

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值