zoukankan      html  css  js  c++  java
  • 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来保护代码
  • 相关阅读:
    一月5日
    一月4日
    Servlet API中forward()与redirect()的区别
    get和post的区别
    java短信验证码实现
    mybatis框架
    springMVC框架
    spring框架
    redis
    MySQL多表查询
  • 原文地址:https://www.cnblogs.com/peiandsky/p/4391682.html
Copyright © 2011-2022 走看看