Is there a way to dynamically get styled attributes?
For instance, to find a resource id, I can use:
context.getResources().getIdentifier("idtofind", "id", context.getPackageName());
Is there something similar to this to get styled attributes?
A little background...I have a library which has a custom sliding drawer. It has custom styled attributes in the project's /values/attrs.xml.
I got it to drop into the UI in the GLE, but it doesn't show up, because it can't find the ids for the handle and content. The line is this:
TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.DrawerSlider, defStyle, 0 );
I'm not sure how to achieve the above, as the styleable is an int array, so getIdentifier() won't work.
EDIT:
Ok, I've been able to get things to work in code fine now, but still having problems with the GLE. I'll try to clarify a bit more now. Like I said, this is for a library, which is freely available.
After testing, I've discovered that using getIdentifier won't work (it always returns 0, unless it's running the app ). Right now, I'm manually parsing the AttributeSet to get the ids of all the attributes I need (handle, content, direction, etc). When the GLE processes this, it returns +id/handle, rather than the resource int representing it.
It seems the only thing that will work for the GLE is to directly feed it the R.id static int. Seeing with the newer versions of ADT (I'm on r17) you can't reference the library's resources, I don't see a way to dynamically feed the resource ids I need.
Right now, it seems the only way to get this to work is to place the source file of the drawer itself in the user's project, which I would really like to avoid if at all possible. It would mean either placing it in the project's source dir upon creation of a new project, or adding a right click submenu command to place it. Both just seem like bad workarounds.