我在ExpandableListView的子级中使用按钮。我已将自定义可绘制对象添加到按钮的背景中,以便它可以为每个状态显示另一个图像。它通常会显示/更新按钮的背景,但有时在特定子项中按下按钮时不会。
这是我用于按钮背景的可绘制对象。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/button_plus_highlight" />
<item android:state_focused="true" android:drawable="@drawable/button_plus_highlight" />
<item android:drawable="@drawable/button_plus_normal"/>
</selector>
在
XML 中的列表视图上添加此参数
android:descendantFocusability="blocksDescendants"
我希望这有帮助。:)