How to set Background of a TextView dynamically from Xml file
<p>I have an XMl file like below which I will use to set background for Textview: <br></p>

<h1>row.xml <br></h1>

<pre><code>      &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
</code></pre>

<p>android:shape="rectangle">
   
   
          
<br> The above Xml I will set as background for TextView in main.xml as below: <br></p>

<h1>main.xml <br></h1>

<pre><code>&lt;TextView
android:id="@+id/rowtext3"
android:text="Availablity"
android:layout_height="25px"
android:layout_width="60px"
android:textSize="10px"
android:textStyle="bold"
android:textColor="@color/black"
android:gravity="center"
android:background="@drawable/row"
/&gt;
</code></pre>

<p><br> But I want this to do from code rather than Xml.I have done everything  that I have done in Xml like font,width,Height,font dynamically through code , but not able to set Background that I mentioned in Xml file . How can we set content of Xml file as background to textview similar to how we set background as XML in main.xml. <br></p>

<p>In the code I have done like this: <br>
        t1=new TextView(this); <br>
        t1.setText(ed1.getText()); <br>
        t1.setHeight(25); <br>
        t1.setWidth(60); <br>
        t1.setTextSize(10); <br>
But I didn't find how to set background i.e. how to set XML content as background? <br>
Can any one help me in sorting out this issue? <br>
Thanks In Advance,</p>
