Define selector in code
<p>I have the following selector:</p>

<pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item&gt;
        &lt;shape android:shape="rectangle"&gt;
            &lt;solid android:color="#00000" /&gt;
            &lt;corners android:radius="10dp" /&gt;
            &lt;stroke android:width="5px" android:color="#FFFFFF" /&gt;
        &lt;/shape&gt;
    &lt;/item&gt;

&lt;/selector&gt;
</code></pre>

<p>Which I want to define in code. I have managed to come as far as this:</p>

<pre><code>StateListDrawable states = new StateListDrawable();

float[] roundedCorner = new float[] { 10, 10, 10, 10, 10, 10, 10, 10 };
float[] innerRoundedCorner = new float[] { 5, 5, 5, 5, 5, 5, 5, 5 };
RectF inset = new RectF(5, 5, 5, 5);
RoundRectShape round = new RoundRectShape(roundedCorner, inset, innerRoundedCorner);        

ShapeDrawable shape = new ShapeDrawable(round);     
shape.getPaint().setColor(Color.WHITE);

states.addState(new int[] {}, shape);

button.setBackgroundDrawable(states);
</code></pre>

<p>This gives me a button with a white edge, but I unable to set the button background color.
How is this achieved in code?</p>
