Search code examples
androidandroid-resourcesandroid-source

finding resources of view


I'm trying to add to my project the source code of SlidingDrawer, I could find it easily in grepCode. The problem is that the code is not compiling, there's references to native resources, for Ex.

R.styleable.SlidingDrawer_orientation

that I'm cannot find, neither in GrepCode nor in Android repositories at GitHub.

does anyone have encountered in such a scenario and was managed to solved it? Thanks.


Solution

  • So I just tried doing this, I had compile errors related to the resources as well. Those resources are not publically available to android.R. As the previous answerwer said, some resources are declared internal/hidden.

    Once I imported my own frameworks_all.jar file I was able to see them and even build my own little SlidingDrawer class, with no more work than just copying the file into my own project.

    This is an excellent guide to get you started on understanding the concepts of / getting used to using Android's hidden and internal classes: Amazing Super Awesome Guide to Android's Internal / Hidden API which will totally work and make your life better

    Note The attributes appear to be hidden, not internal, so you just need to worry about getting access to hidden components.

    A bit of background if you are interested though, the resource file for android (android.R) gets compiled specially in frameworks/base. The attribute you want doesn't appear to exist on it's own, I.E. there is no xml file in frameworks base where R.styleable.SlidingDrawer_orientation exists. That's why you couldn't just find it. There IS however, an attribute file: frameworks/base/core/res/res/values/attrs.xml which you can find the orientation listed as an attribute for:

    <!-- SlidingDrawer specific attributes. These attributes are used to configure
         a SlidingDrawer from XML. -->
    <declare-styleable name="SlidingDrawer">
        <!-- Identifier for the child that represents the drawer's handle. -->
        <attr name="handle" format="reference" />
        <!-- Identifier for the child that represents the drawer's content. -->
        <attr name="content" format="reference" />
        <!-- Orientation of the SlidingDrawer. -->
        <attr name="orientation" />
    ...
    

    Seems like android marks all the styleable attributes hidden because the entire section is obscured from public code. I'm not sure of the specifics in how this R file gets constructed, I'd have to dig more into make files to find out. Either way, end fluff, to reiterate all you need to do is get access to the internal/hidden components.