snipt

Ctrl+h for KB shortcuts

Text only

drawable from string

String mDrawableName = "myimg";
int resID = getResources().getIdentifier(mDrawableName , "drawable", getPackageName());
https://snipt.net/embed/32d4e3d84d3efd75b011cab2678547b9/
/raw/32d4e3d84d3efd75b011cab2678547b9/
32d4e3d84d3efd75b011cab2678547b9
text
Text only
2
2019-06-18T13:33:46
True
False
False
Aug 02, 2016 at 12:12 PM
/api/public/snipt/147495/
drawable-from-string
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>String mDrawableName = &quot;myimg&quot;; </span><span id="L-2"><a name="L-2"></a>int resID = getResources().getIdentifier(mDrawableName , &quot;drawable&quot;, getPackageName()); </span></pre></div> </td></tr></table>
android, drawable, resource, string