Get value of a custom attribute in Java Code
<p>I create an attribute in attrs.xml file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;resources&gt;
    &lt;declare-styleable name="Custom"&gt;
        &lt;attr name="src" format="integer" /&gt;
    &lt;/declare-styleable&gt;
&lt;/resource&gt;
</code></pre>

<p>And in my code, I get the value of the attribute like this:
attrs.getAttributeIntValue("mynamespace", "src", -1);</p>

<p>It works. I get the value of 'src' from the layout xml file.
But my question is why android does not generate a value in R class so that I don't need to use the string 'src' again in my java code?</p>

<p>Than kyou.</p>
