Android id naming convention: lower case with underscore vs. camel case

后端 未结 8 651
北荒
北荒 2020-11-30 21:26

I\'m currently programming an application for the Android. Now what I found out is that you cannot place resource objects, say, an image in the drawable folder and name it l

8条回答
  •  情话喂你
    2020-11-30 22:17

    i think it is good if we use the all small letters with underscores.

    Just look at this(Adding to what Daniel had answered)

      // Camel Case
        TextView tvUserName = (TextView) findViewById(R.id.tvUserName);
    
        // Small Caps and Underscores
        TextView tvUserName = (TextView) findViewById(R.id.tv_user_name);
    

    in my own experience I tend to get a little confused of the camel case convention in xml because when you link it to Java which also uses camel case(because it is the standard) it looks like a doppleganger.

提交回复
热议问题