Android命名规范(自定义)(转载)

原文地址:http://www.cnblogs.com/xiaoQLu/archive/2012/11/27/2790539.html

认真对比了下,发现原作者非常认真呀呵呵。

总体规范:

  类名要清晰,能反映出这个类的作用,最好能达到见名知义的效果

  方法名要使用动宾短语 eg: public boolean moveTaskToBack(boolean nonRoot);

  构造函数使用pascal命名规则,又叫大驼峰规则,首字母大写

  普通方法和成员变量采用小驼峰规则(camel规则),首字母小写

  普通方法的局部变量采用下划线规则,以_开头

1.类的成员变量

  所有公开的类常量:定义为静态final类型,名称全部大写 eg: public static final String ACTION_MAIN = "android.intent.action.MAIN";

  静态变量:名称以s开头 eg: private static long sInstanceCount = 0;

  非静态的私有变量,protected的变量:以m开头 eg: private Intent mIntent;protected ViewParent mParent;

2.方法的命名

  方法参数:名称以p开头,表示param的意思 eg: public int getCount(int pCount);

  方法内的局部变量_开头,

    eg public int getCount (int pCount){

        int _count;

      }  

原文地址:https://www.cnblogs.com/draem0507/p/3133128.html