I have an issue with my ImageButton not changing state. When I click, or rather touch, the button it stays as the same image. Here is the XML I am using as a selector.
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/pushed" />
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/pushed" />
<item
android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/pushed" />
<item
android:drawable="@drawable/default" />
</selector>
I call this selector from my main.xml as
android:background="@drawable/imagechoice"
imagechoice.xml is the file with the selector
I don't understand why this is not working, unless I have to have some java code, but everything I've seen said this should work.
When using an ImageButton, isn't it the 'src' property you should use and not background?
Make sure that you copy the same images and the button XML into every "drawable" folders (hdpi,ldpi,mdpi). That's how I solved this problem on my app.
Good luck :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With