码迷,mamicode.com
首页 > 其他好文 > 详细

As of ADT 14, resource fields cannot be used as switch cases

时间:2014-10-09 14:02:03      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:android   style   color   io   os   使用   ar   java   for   

 
 

在导入Android Sample的ApiDemos的时候,发现R.id.xx的文件不能够在 switch cases 中使用 在google查询了下,找到以下答案:

As of ADT 14, resource fields cannot be used as switch cases. In other words, the constants are not final in a library project. The reason for this is simple: When multiple library projects are combined, the actual values of the fields (which must be unique) could collide. Before ADT 14, all fields were final, so as a result, all libraries had to have all their resources and associated Java code recompiled along with the main project whenever they were used. This was bad for performance, since it made builds very slow. It also prevented distributing library projects that didn‘t include the source code, limiting the usage scope of library projects. 

解决的方法是把switch cases 改成 if else的方式,在eclipse中可以使用 ctrl+1快捷方式切换。

As of ADT 14, resource fields cannot be used as switch cases

标签:android   style   color   io   os   使用   ar   java   for   

原文地址:http://www.cnblogs.com/xgjblog/p/4012808.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!