dsdsdsdsd
dsdsdsdsd

Reputation: 2962

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

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

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

QUESTION: how does android find these xml's?

thanks, Shannon

Upvotes: 0

Views: 853

Answers (2)

locoboy
locoboy

Reputation: 38920

All the xml files get sent to the R.java class. They're assigned specific integer IDs that can be referenced in your java code.

when you say setContentView(R.layout.main) you're getting the integer ID and passing it to the content view. This R class then redirects it to your xml.

Upvotes: 2

Mats Hofman
Mats Hofman

Reputation: 7240

You can get to these files using the R class. For example when you want to set your contentview to main.xml you do it like this setContentView(R.layout.main);

if you want to reach a String from a XML you can do it like this getResources().getString(R.string.appname);

Also take a look at the Application Resources section of the Dev Guide http://developer.android.com/guide/topics/resources/index.html

Upvotes: 2

Related Questions