• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

how does android app find res.layout.main.xml

dsdsdsdsd

Newbie
hello;


I'm new to eclipse and android ... just finished my first eclipse/adt tutorial.



I don't see see anything in the manifest.xml that points to res.layout.main.xml or res.values.strings.xml.


QUESTION: how does android find these xml's?


thanks, Shannon
 
When you build a project, everything from res is generated into a file called R.java

You then access it in your java code like this:
Code:
setContentView(R.layout.main);

myTextView.setText(  getString( R.string.hello )  );
 
so, is it fair to say that the main.xml and the strings.xml are only used during authoring ...

during "run as android app" process their info's are being re-written into the R.java ... right??

in other words, the main.xml and the strings.xml never actually make it to the android device ... is this right??
 
/res/values/strings.xml* gets compiled in (sorta), but the other xml stays in the apk.

*(although I'm not 100% sure but it might be the whole /res/values folder)


But it all gets set to an R variable for targeting from within your app. R basically is just pointers to the resources. You can open it up and look at it, you'll see all the IDs you've named in the XML with a hex address like 0x704e52


All you really need to know is that in your app you should use R
 
Back
Top Bottom