My layout has two buttons. By default they have background "A". When one button is clicked/pressed, the background of that button should change to background "B" and the other button would have background "C". And the other way around.
I tried to set this with selector:
<?xml version="1.0" encoding="UTF-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/buttonClicked" /> <item android:state_selected="true" android:drawable="@drawable/buttonClicked" /> <item android:drawable="@drawable/abutton" /> </selector>
and then in MainActivity I set:
Button btnTrue = FindViewById<Button>(Resource.Id.buttonTrue); btnTrue.Selected = true;
btnTrue.Pressed = true; has no effect.
If I add
<item android:state_selected="false" android:drawable="@drawable/buttonClicked" /> then this is default background.
I tried to use android:state_focused true and false but it has no effect.
And focused state can not be set in code like
btnTrue.Focused = true;
So what would be the solution to my problem?