Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to dynamically load R.styleable resource?
    primarykey
    data
    text
    <p>I'm trying to export the Facebook Android SDK as a JAR for use in my project.</p> <p>This requires loading all the resources dynamically. </p> <p>For example, I have to make changes similar to this:</p> <pre><code>//findViewById(R.id.com_facebook_login_activity_progress_bar).setVisibility(View.VISIBLE); int viewID = getResources().getIdentifier("com_facebook_login_activity_progress_bar", "id", getPackageName()); findViewById(viewID).setVisibility(View.VISIBLE); </code></pre> <p>The commented line shows the original, and the 2 lines below show the change I made to load the same resource dynamically.</p> <p>The Facebook SDK declares a R.styleable resource, and I can't figure out how to load it dynamically. Here's the original code:</p> <pre><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(); } </code></pre> <p>Then in attrs.xml, the following is declared: </p> <pre><code> &lt;declare-styleable name="com_facebook_profile_picture_view"&gt; &lt;attr name="preset_size"&gt; &lt;!-- Keep in sync with constants in ProfilePictureView --&gt; &lt;enum name="small" value="-2" /&gt; &lt;enum name="normal" value="-3" /&gt; &lt;enum name="large" value="-4" /&gt; &lt;/attr&gt; &lt;attr name="is_cropped" format="boolean" /&gt; &lt;/declare-styleable&gt; </code></pre> <p>How can I load this resource dynamically, (e.g. replace the R.styleable reference) ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload