I have a mute button on my Android app. I would like to have 2 states for it: 1. sound on 2. sound off
For each state there is a different background:
So when pressed I would like the Sound off image to be displayed and HELD. When pressed a second time I would like the Sound On image to display again.
Here is my code so far:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/soundoff"></item>
<item android:state_checked="true" android:drawable="@drawable/soundoff"></item>
<item android:drawable="@drawable/soundon"></item>
</selector>
The problem I am having is that although the background changes when the button is selected, I would like that background to be held until the next selection.