You can declare IDs in your res/values/resources.xml file, like this:

<resources>
  <item type="id" name="common_control_01"/>
  <item type="id" name="common_control_02"/>
</resources>

Then, refer to the id in your layout simply with @id/common_control_01

If you have a bunch of common IDs, this might be a good approach.

Regards,
Jef


On Aug 24, 3:02 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> On Tue, Aug 24, 2010 at 5:06 PM, Doug Gordon <gordo...@gmail.com> wrote:
> > I'm just getting into developing my app, which will have quite a
> > number of activities and thus quite a few XML files to lay out the
> > screens and define all the views. What I'm just seeing is that if I
> > assign the IDs using "@+id/name", I'll have to have a unique name for
> > every widget on every screen since all the symbols get defined in one
> > big R.java file.
>
> > Or can I just generate the definitions once in one of the XML files
> > and then reference them in the other layout files? For example, if I
> > have a TextView that I'd like to call "surname" in multiple layout
> > files, can I declare it one of the files using "@+id/surname" and then
> > simply use "@id/surname" in the other files? I assume that as long as
> > all the IDs are unique within a layout file, all is OK.
>
> No, you can't declare it that way. However, if you use @+id/surname
> multiple times, only one R.id.surname entry goes in R.java.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 3.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to