I have the following selector for a button (with 2 states, regular and pressed):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<solid
android:color="#3498DB" />
<stroke
android:width="1dp"
android:color="#2980B9" />
<corners
android:radius="0dp" />
<padding
android:left="12dp"
android:top="12dp"
android:right="12dp"
android:bottom="12dp" />
</shape>
</item>
<item>
<shape>
<solid
android:color="#2980B9" />
<stroke
android:width="1dp"
android:color="#2980B9" />
<corners
android:radius="0dp" />
<padding
android:left="12dp"
android:top="12dp"
android:right="12dp"
android:bottom="12dp" />
</shape>
</item>
</selector>
My button has the following which specifies the background as the above selector:
<Button
android:id="@+id/button_LaunchShiftsGame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ShiftsMode"
android:background="@drawable/selector_Button"
style="@style/Button_Text" />
I need to access and change the colors for both states from code when the Activity loads.
How can I do this?