最近在做項目的時候,遇到的問題,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"