在ListView的Item中,如果有Button控件,那么要实现Button和Item点击都有响应,可以将Item的Layout中Button的focusable属性设为false,然后设置layout的属性android:descendantFocusability="blocksDescendants"。
代码如下:
本文介绍如何在Android ListView的Item中配置Button,确保两者点击事件都能正常触发。通过设置Button的focusable属性为false,并将Item布局的descendantFocusability属性设置为blocksDescendants,可以实现这一目标。
在ListView的Item中,如果有Button控件,那么要实现Button和Item点击都有响应,可以将Item的Layout中Button的focusable属性设为false,然后设置layout的属性android:descendantFocusability="blocksDescendants"。
代码如下:
5985

被折叠的 条评论
为什么被折叠?