最近在做项目的时候,遇到的问题,GridView的Item中含有Button或者ImageButton时,GridView的Item点击无效。
后来发现是Button、ImageButton会把GridView的Item的点击事件截取。
解决方法:
在adapter的布局中找到对应的Button添加属性 android:focusable="false"
如果是ImageButton 则要添加android:focusable="false" 还需要在当前adapter的xml布局 最外层的那个layout添加
android:descendantFocusability="blocksDescendants"