When working through the tutorial to build my first Android application I reached a section where it states the @+id/
prefix not only references a resource that is defined in the gen/R.java
file, but that the +
sign also indicates its first encounter with it so it will create it. Consider this code snippet:
<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
After reading through the side-bar in the first link, related to resources, and the article it linked to named Providing Resources (at a somewhat cursory level), I'm unable to get a very clear statement from the documentation on the scope of the resource with the @+id/
prefix. I understand that you can have a resource with the same name scoped inside each prefix:
Note: This string resource has the same name as the element ID: edit_message. However, references to resources are always scoped by the resource type (such as id or string), so using the same name does not cause collisions.
but what I'm driving at is this. Based on the documentation it appears that I can't have two controls resourced as edit_message
in two different activities because there would be a conflict.
My concern here is that I'd presumably have to prefix my id
attributes with the Activity
name to keep them unique so I can access these controls from code.
Am I correct in my statement and assumptions here?