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

后端 未结 8 650
北荒
北荒 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:18

    android:id="@+id/frag_account_button"
    frag_account_button = ((ListView)view.findViewById(R.id.frag_account_button));
    
    android:id="@+id/fragAccountButton"
    fragAccountButton = ((ListView)view.findViewById(R.id.fragAccountButton));
    

    First of all, there is no certain standard to define which one is more Proper but I have my own idea about that. My idea is reasonable to keeping XML id and java variable in the exact same name with the camel-case convention.

    1. It is easy to reach the variable by searching for the project both XML and java side.

    2. butterKnife library definition

      @BindView(R.id.infoTextView) TextViewFont infoTextView;

    It is more proper to keep in this way.

提交回复
热议问题