I am trying to export the Android Android SDK as a JAR for use in my project.
This requires loading all resources dynamically.
For example, I need to make the following changes:
int viewID = getResources().getIdentifier("com_facebook_login_activity_progress_bar", "id", getPackageName());
findViewById(viewID).setVisibility(View.VISIBLE);
The marked line shows the original, and the two lines below show the change I made to dynamically load the same resource.
The Facebook SDK announces the R.styleable resource, and I cannot figure out how to load it dynamically. Here is the source code:
private void parseAttributes(AttributeSet attrs) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_profile_picture_view);
setPresetSize(a.getInt(R.styleable.com_facebook_profile_picture_view_preset_size, CUSTOM));
isCropped = a.getBoolean(R.styleable.com_facebook_profile_picture_view_is_cropped, IS_CROPPED_DEFAULT_VALUE);
a.recycle();
}
Then the following is declared in attrs.xml:
<declare-styleable name="com_facebook_profile_picture_view">
<attr name="preset_size">
<enum name="small" value="-2" />
<enum name="normal" value="-3" />
<enum name="large" value="-4" />
</attr>
<attr name="is_cropped" format="boolean" />
</declare-styleable>
How can I load this resource dynamically (for example, replace the R.styleable link)?
source
share