`

ListView与Button的共存问题解决

阅读更多

如果listview 的item里面有button,imagebutton,往往会造成click事件被button截取,而listview的item收不到click事件,通过google,发现需要做两件事情

1 在item的布局中给我们最大的layout设置1个属性 android:descendantFocusability="blocksDescendants" 

  blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点

2 在button里面加android:focusable="false"

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics