GridView的Item中含有Button或者ImageButton時,Gallery 的Item點擊無效

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章