How to use a drawable shape in Android through Java?
<p>If I have a drawable shape:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; 
&lt;shape xmlns:android="http://schemas.android.com/apk/res/android" 
 android:shape="rectangle"&gt; 
 &lt;stroke android:width="2dp" android:color="#FFFFFFFF" /&gt;
 &lt;gradient android:startColor="#DD000000" android:endColor="#DD2ECCFA" 
        android:angle="225"/&gt; 

&lt;corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" 
 android:topLeftRadius="7dp" android:topRightRadius="7dp"/&gt; 
&lt;/shape&gt; 
</code></pre>

<p>How would I go about using this as the background for a textview? I tried something like below, but it didn't work.</p>

<pre><code>TextView jObjTv = new TextView(getActivity());
jObjTv.setBackgroundDrawable(findViewById(R.drawable.sample_box));
</code></pre>
