android listView设置了点击事件 点击无效
来源:互联网 发布:用u盘重装mac 编辑:程序博客网 时间:2024/06/07 00:34
一.问题引入
ListView控件:给Item设置了点击事件,却没有效果。
二.解决方案
ListView使用了自定义布局文件,在布局文件中有button等控件时,这些控件获取焦点的级别比listView的item高,所以当点击item时,button等控件会优先获得点击焦点。
解决方法就是在布局文件根元素中添加属性: Android:descendantFocusability="blocksDescendants"
android:descendantFocusability
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会覆盖子类控件而直接获得焦点
0 0
- android listView设置了点击事件 点击无效
- android listview item setOnItemClickListener 点击事件无效
- Android开发:ListView控件:给Item绑定了点击事件,却点击无效
- android listview添加headview,点击事件设置!
- Android Button 点击事件无效
- ListView Item点击事件无效,不响应
- ListView中点击ITEM单击事件无效。
- android listView-simpleadapter(点击事件)
- android ListView Item 点击事件
- android ListView 点击事件失效
- Android ListView(三) 点击事件
- Android listview模拟点击事件
- Android listview的item点击事件怎么失效了?
- Android ListView 中的按键点击事件的设置
- android listview item 点击无效解决
- android ListView解决Item点击无效
- Android ListView setOnItemClickListener点击无效原因分析
- ListView.setOnItemClickListener 点击无效
- php 枚举问题
- java主键生成
- java源码分析(2)-String(1)
- 利用测试工具Loadrunner,刷博客访问量与积分实战
- 导航页面ViewPager和欢迎界面的实现
- android listView设置了点击事件 点击无效
- codeforces round 348 div2
- AES加密算法,JAVA实现示例
- Struts2中action 访问servlet API
- android editview 点击弹出输入法时,不把标题栏顶出窗体之外
- UISegmentedControl
- 5种服务器网络编程模型讲解
- Android平台的跨进程通信——AIDL(上)
- 干货文章和优秀的第三方链接