title: Android create selector programmatically
body: <p>How can i create selector programmatically?<br>
  i have a xml selector that assigned to <code>TabWidget</code> as <code>Tab indicator color</code> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;!-- Non focused states --&gt;
      &lt;item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/bg_tab_unselected" /&gt;
      &lt;item android:state_focused="false" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/bg_tab_selected" /&gt;
  
      &lt;!-- Focused states --&gt;
      &lt;item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/bg_tab_unselected_focused" /&gt;
      &lt;item android:state_focused="true" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/bg_tab_selected_focused" /&gt;
  
      &lt;!-- Pressed --&gt;
      &lt;!--    Non focused states --&gt;
      &lt;item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/bg_tab_unselected_pressed" /&gt;
      &lt;item android:state_focused="false" android:state_selected="true"  android:state_pressed="true" android:drawable="@drawable/bg_tab_selected_pressed" /&gt;
  
      &lt;!--    Focused states --&gt;
      &lt;item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/bg_tab_unselected_pressed" /&gt;
      &lt;item android:state_focused="true" android:state_selected="true"  android:state_pressed="true" android:drawable="@drawable/bg_tab_selected_pressed" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>Is there any way to create above xml code dynamically?</p>