I have a problem with changing the state of ImageButton. When I click or rather touch the button, it remains as the same image. Here is the XML that I use 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 a file with a selector
I do not understand why this does not work, unless I have Java code, but everything I saw says that this should work.
source share