They are unique to the entire project, but can be used in different contexts. The reason is quite simple: there will be only one variable R.id.name_of_id, although they cannot be referenced anywhere. I mean, if you have an identifier with a name @+id/my_idthat is in the file my_layout.xml, you cannot use it unless you are currently working with my_layout.xmlimplicitly or explicitly. Implication using findViewByIdafter a call setContentView(R.layout.my_layout.xml)(from an action) or explication using it from an object (for example, when you “inflate” a layout and assign it to an object View, you can do it object.findViewById()).
source
share