我的 ImageButton 没有改变状态有问题。当我单击或触摸按钮时,它会保持相同的图像。这是我用作选择器的 XML。
<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>
我从我的 main.xml 中将此选择器称为
android:background="@drawable/imagechoice"
imagechoice.xml 是带有选择器的文件
我不明白为什么这不起作用,除非我必须有一些 java 代码,但我所看到的一切都说这应该起作用。