V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
huchenqiang90
V2EX  ›  问与答

关于android编程的一个习惯问题

  •  
  •   huchenqiang90 · 2013-03-19 16:34:18 +08:00 · 2290 次点击
    这是一个创建于 4064 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近我发现很多人在android内部创建属性的时候都是m开头的,谁知道这是为啥?如果是一个习惯的话,什么由来呢,thank you!
    2 条回复    1970-01-01 08:00:00 +08:00
    madeye
        1
    madeye  
       2013-03-19 16:38:20 +08:00
    Non-public, non-static field names start with m.

    Static field names start with s.

    Other fields start with a lower case letter.

    Public static final fields (constants) are ALL_CAPS_WITH_UNDERSCORES.

    详见:http://source.android.com/source/code-style.html#follow-field-naming-conventions
    michaelye1988
        2
    michaelye1988  
       2013-03-19 16:48:09 +08:00
    如果是布局文件中的某个控件,我习惯用这个控件的缩写打头,然后加上能够说明这个控件的作用的单词。比如:TextView tvTitle(标题),Button btnBack(返回按钮)等。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2429 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 09:43 · PVG 17:43 · LAX 02:43 · JFK 05:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.