本文主要是介绍Android Migrate Android Code,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
近期在更改程序架构的时候,用引用Library的方式实现程序的共享化过程中发现R.id.xx的文件不能够在 switch cases 中使用看代码提示,如下信息:
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快捷方式切换。
这篇关于Android Migrate Android Code的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!