ListView点击事件失效(item里面有button按钮控件)解决方法

ListView点击事件失效解决方法:

一般出现这个情况,就是你的item里面有按钮的点击事件,你的item里面有button控件,button控件是抢占焦点的,只要在你的item布局里面这样子写就可以了:

                   <Button
                    android:layout_width="140px"
                    android:layout_height="56px" android:text="按钮" android:textSize="28px" android:focusable="false" android:textColor="@color/white"/>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

注意: android:focusable=”false”只要加上这句话,就可以避免了抢占焦点事件

猜你喜欢

转载自www.cnblogs.com/zmc/p/9288123.html