Android Widget Identity Naming Policy

Asked 2 years ago, Updated 2 years ago, 42 views

How do you usually name the ID that you want to attach to the widget on Android activity?

As far as looking at the ApiDemos etc. included with the SDK, for example, the same button does not seem to be particularly consistent, such as btn_…, …_button, and (verb only) as shown below.Do you mean that the only thing in common is the snake case?

<Button android:id="@+id/toggle_home_as_up"…
<Button android:id="@+id/btn_add_tab"…
<Button android:id="@+id/one_shot"…
<Button android:id="@+id/progress_button"…

It doesn't have to be official, so I would appreciate it if you could give me some guidelines, but could you please let me know if you have any good information?

android

2022-09-30 19:50

1 Answers

I answered below, but I am sorry for the appropriate answer.
If you say no in advance, it's easy to reach a consensus and your boss agrees immediately
There was no authoritative coding style.

I had a similar question at home, so I skimmed through it, but as of 2011, there were no official rules.
Are there events on how to name resources?

From the above question, if you want to salvage a certain rule,
·The xml file name must be either a-z lowercase letter, 0-9 or "_"
→The widget ID name is the same
·Snake case (_ must separate words from words)
·The icon prefix is Determined

It was about .
Also, according to the Android cheat sheet for designers,
It seems that there are SDK rules for drawable prefixes...

In my personal opinion,
You can find the coding style (e.g. Google) if you look for it, so
Camel Case ス Conscious of Snake Case Interconversion
Make sure you don't call the English police even if you use the widget's ID as a method
I'm careful.

Thank you for your cooperation.


2022-09-30 19:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.