V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
huchenqiang90
V2EX  ›  问与答

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

  •  
  •   huchenqiang90 · Mar 19, 2013 · 3024 views
    This topic created in 4801 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   ·   1386 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 17:08 · PVG 01:08 · LAX 10:08 · JFK 13:08
    ♥ Do have faith in what you're doing.