android最佳实践的建议(翻译自android-best-practices)

Best practices in Android development

Use Gradle and its recommended project structure
使用Gradle和其推荐的工程结构
Put passwords and sensitive data in gradle.properties
将密码和敏感数据放置在gradle.properties中
Don't write your own HTTP client, use Volley or OkHttp libraries
不要自己写http的客户端对接,使用开源框架Volley和OkHttp(译者:其实还有其他几个也不错,request,loopj)
Use the Jackson library to parse JSON data
使用Jaskson来解析json数据(译者:fastjson的android版本也不错)
Avoid Guava and use only a few libraries due to the 65k method limit
因为android  65k方法数量限制,避免使用Guava开源包,只使用少量开源包(译者:因为android支持的方法数量65536个,所以要特别注意)
Use Fragments to represent a UI screen
使用Fragment来展现界面
Use Activities just to manage Fragments
使用Activity来管理Fragment
Layout XMLs are code, organize them well
布局xml也是程序,要好好管理
Use styles to avoid duplicate attributes in layout XMLs
使用样式来避免在布局xml中重复的配置参数
Use multiple style files to avoid a single huge one
使用多个样式配置避免集中到一个巨大的样式配置文件
Keep your colors.xml short and DRY, just define the palette
保持color.xml简短,只配置调色板的几个颜色即可
Also keep dimens.xml DRY, define generic constants
同样保持dimens.xml简短,只配置通用的常量
Do not make a deep hierarchy of ViewGroups
不要让布局的层次很深
Avoid client-side processing for WebViews, and beware of leaks
避免在客户端处理多个webview,尤其注意对象溢出
Use Robolectric for unit tests, Robotium for connected (UI) tests
使用Robolectric进行单元测试,Robotium进行UI连接测试
Use Genymotion as your emulator
使用Genymotion作为模拟器
Always use ProGuard or DexGuard
坚持使用Proguard和DexGuard来保护代码

 

转载于:https://www.cnblogs.com/peiandsky/p/4391682.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值