Are you using Eclipse or Ant? For Ant, R. java is updated whenever you build. For Eclipse, it's going to depend on the config.
- If you add/delete/edit the file outside of Eclipse, make sure you refresh the workspace (or set it up to refresh automatically) so that Eclipse can see the changes. - Eclipse can either build on demand or on any file changes. If set to manual, then you'll need to launch a compile after any resource change (same for Ant basically). Both needs to happen for R.java to be updated: Eclipse must see the change (possible refresh needed), and Eclipse must compile the project. Personally, I set Eclipse to refresh automatically and to auto-build. Xav On Sun, May 9, 2010 at 1:06 AM, Daniel Favela <[email protected]> wrote: > On this note, I was wondering: when exactly is R.java updated? Here are > some cases that have caused confusion for me. > > - I add a new file in the res/layout folder. R.java is NOT updated with my > new xml file. > > I perform a CLEAN on the project and then... > - I delete a file such that main.xml is the only file remaining. R.java IS > updated! > - I delete a file after having added two -- that is, main.xml is not the > only file remaining. R.java is NOT updated. > > Any ideas? I especially am interested in making the R.java file pointing to > the newly added xml files (case 1 of the three in my list). > > -Danny > > On Sat, May 8, 2010 at 7:23 PM, joshua hublar <[email protected]> > wrote: >> >> Android considers XML-based layouts to be resources, and as such layout >> files are stored >> in the res/layout directory inside your Android project. >> Each XML file contains a tree of elements specifying a layout of widgets >> and their containers >> that make up one view hierarchy. The attributes of the XML elements are >> properties, describing >> how a widget should look or how a container should behave. For example, if >> a Button element >> has an attribute value of android:textStyle = "bold", that means that the >> text appearing on >> the face of the button should be rendered in a boldface font style. >> Android’s SDK ships with a tool (aapt) which uses the layouts. This tool >> should be auto- >> matically invoked by your Android tool chain (e.g., Eclipse, Ant’s >> build.xml). Of particular >> importance to you as a developer is that aapt generates the R.java source >> file within your >> project, allowing you to access layouts and widgets within those layouts >> directly from your >> Java code. >> >> On Sat, May 8, 2010 at 9:48 PM, Ubuntu Explorer <[email protected]> >> wrote: >>> >>> Hello , >>> >>> Why is R.java named so? >>> >>> It seems to store "IDs" in static variables like R.layout etc. >>> It looks like this is Android's way of keeping track of predefined UI >>> elements in the Manifest file. >>> >>> Is it possible to access Views created during runtime using the same >>> class "R"? >>> >>> Regards, >>> UE. >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Android Beginners" group. >>> >>> NEW! Try asking and tagging your question on Stack Overflow at >>> http://stackoverflow.com/questions/tagged/android >>> >>> To unsubscribe from this group, send email to >>> [email protected] >>> For more options, visit this group at >>> http://groups.google.com/group/android-beginners?hl=en >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Beginners" group. >> >> NEW! Try asking and tagging your question on Stack Overflow at >> http://stackoverflow.com/questions/tagged/android >> >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-beginners?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- Xavier Ducrohet Android SDK Tech Lead Google Inc. Please do not send me questions directly. Thanks! -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

