Listview中item与button类控件获取焦点问题

为listiew设置item中含有Button类控件时,item失去焦点,不响应onclick事件,通过度娘,谷哥发现,item中有button类控件时,item失去焦点,因此可以通过两种方法解决

1.item中的button控件 android:focusable="false",即button类控件主动失去焦点,

2. Listview属性加入android:descendantFocusability="blocksDescendants"  ,即阻止子控件获得焦点。

 

你可能感兴趣的:(android,ListView,button)