It is magical for Android to locate the proper resource just through the R.id.XXX.
AFAIK, the resources are compiled to binary format, so how does this mapping logic work under the hood?
Maybe it works like this:
For e.g., in the layout1.xml, we got:
<Button android:id="@+id/button1" >
and AAPT will generate this in the R.java:
public static final int button1=0x7f05000b;
When the *.apk is genrated, the @+id/button1 with be substituded with "0x7f05000b".
Thus, when we call:
findViewById(R.id.button1);
we are essentially still do the search based on the ID, though the ID is a number like 0x7f05000b.
Thanks!
What I really want to know, is how the resource id integer is parsed into the resource content? In other words, how does the Android runtime locate the resource content with resource id as the sole clue?
For example, how is a drawable picture found with a resource id? Or how is a string value is found with a resource id?