android - Resource scope for @+id/ declarations? -
when working through tutorial build first android application reached section states @+id/
prefix not references resource defined in gen/r.java
file, +
sign indicates first encounter create it. consider 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 side-bar in first link, related resources, , article linked named providing resources (at cursory level), i'm unable clear statement documentation on scope of resource @+id/
prefix. understand can have resource same name scoped inside each prefix:
note: string resource has same name element id: edit_message. however, references resources scoped resource type (such id or string), using same name not cause collisions.
but i'm driving @ this. based on documentation appears can't have 2 controls resourced edit_message
in 2 different activities because there conflict.
my concern here i'd presumably have prefix id
attributes activity
name keep them unique can access these controls code.
am correct in statement , assumptions here?
you can place exact block of xml in layout file , work fine. @+id generates new id if not defined yet. when app gets packaged, packaging tool create id once , others correctly refer id.
as long don't end 2 ui components in same layout same id, everything's ok.
Comments
Post a Comment