首页 > 移动平台 > 详细

Android_listview点击失效

时间:2015-03-18 17:20:50      阅读:267      评论:0      收藏:0      [点我收藏+]

listview点击失效,原因可能是item布局中存在Button,该Button夺取了焦点。

解决办法:

1,在xml布局中,为Button添加android:focusable="false"

2,在item布局的根据点添加android:descendantFocusability="blocksDescendants"

Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.
 
Must be one of the following constant values.  
该属性是当一个view获取焦点时,定义viewGroup和其子控件两者之间的关系。
 
属性的值有三种:
 
        beforeDescendants:viewgroup会优先其子类控件而获取到焦点
 
        afterDescendants:viewgroup只有当其子类控件不需要获取焦点时才获取焦点
 
        blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点
3,不要用Button,而是TextView代替,至于点击效果,再另写。

Android_listview点击失效

原文:http://www.cnblogs.com/wangziqiang/p/4347596.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!