【完美解决】Android ListView item 点击没有响应的问题
2016-09-08 20:27
621 查看
若在监听了item布局中的任意一个view的点击事件,那么就会引起整个item点击没有响应的问题了,因为焦点聚焦在item里监听的view中。
那么现在来看下解决的方法:
1、在item里监听的view的xml布局中加入
例如:
2、在item的xml根布局中加入
descendantFocusability的属性有以下三种:
beforeDescendants:优先其子类控件而获取到焦点
afterDescendants:只有当其子类控件不需要获取焦点时才获取焦点
blocksDescendants:覆盖子类控件而直接获得焦点
所以,在这边我们使用blocksDescendants,来解决问题。
例如:
那么现在来看下解决的方法:
1、在item里监听的view的xml布局中加入
android:focusable="false"
例如:
<ImageButton android:id="@+id/ibtn_play_song_list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:focusable="false" />
2、在item的xml根布局中加入
android:descendantFocusability="blocksDescendants"
descendantFocusability的属性有以下三种:
beforeDescendants:优先其子类控件而获取到焦点
afterDescendants:只有当其子类控件不需要获取焦点时才获取焦点
blocksDescendants:覆盖子类控件而直接获得焦点
所以,在这边我们使用blocksDescendants,来解决问题。
例如:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:descendantFocusability="blocksDescendants" android:orientation="vertical"> </LinearLayout>
相关文章推荐
- 完美实现Android ListView中的TextView的跑马灯效果
- android上改变listView的选中颜色
- Delphi7中Listview的常用功能汇总
- Delphi控件ListView的属性及使用方法详解
- C#中ListView控件实现窗体代码
- 基于jQuery实现点击列表加载更多效果
- Android ListView弹性效果的实现方法
- android中ListView数据刷新时的同步方法
- Android提高之ListView实现自适应表格的方法
- Android中实现水平滑动(横向滑动)ListView示例
- Android ListView分页功能实现方法
- ListView实现下拉刷新加载更多的实例代码(直接拿来用)
- C#实现ListView选中项向上或向下移动的方法
- JS简单实现点击复制链接的方法
- Android ListView滑动删除操作(SwipeListView)
- JAVASCRIPT 点击显示 隐藏层
- C#下listview如何插入图片
- C#实现让ListBox适应最大Item宽度的方法
- 关于javascript中限定时间内防止按钮重复点击的思路详解
- javascript点击才出现验证码