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"

猜你喜欢

转载自q364035622.iteye.com/blog/1849086