huchenqiang90
V2EX  ›  问与答

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

  •  
  •   huchenqiang90 · Mar 19, 2013 · 3039 views
    This topic created in 4808 days ago, the information mentioned may be changed or developed.
    最近我发现很多人在android内部创建属性的时候都是m开头的,谁知道这是为啥?如果是一个习惯的话,什么由来呢,thank you!
    2 replies    1970-01-01 08:00:00 +08:00
    madeye
        1
    madeye  
       Mar 19, 2013
    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  
       Mar 19, 2013
    如果是布局文件中的某个控件,我习惯用这个控件的缩写打头,然后加上能够说明这个控件的作用的单词。比如:TextView tvTitle(标题),Button btnBack(返回按钮)等。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5487 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:56 · PVG 16:56 · LAX 01:56 · JFK 04:56
    ♥ Do have faith in what you're doing.