listview或gridview中item的点击事件与控件点击事件冲突的解决
2016-10-25 15:31
399 查看
listview中item的点击事件与控件点击事件冲突的解决:
遇到的问题:listview条目点击事件无法处理事件。listview里的控件抢先收到了事件。
方式1:设置包含所有控件的父view的 descendantFocusability属性。android:descendantFocusability=”blocksDescendants”
2.方式二。设置 子控件的android:focusable=”false” 属性。
总结来说,是事件分发与消费问题。由于时间限制,先列出解决方案。以后完善分析。
遇到的问题:listview条目点击事件无法处理事件。listview里的控件抢先收到了事件。
方式1:设置包含所有控件的父view的 descendantFocusability属性。android:descendantFocusability=”blocksDescendants”
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:descendantFocusability="blocksDescendants" android:layout_height="match_parent" android:orientation="vertical"> <Button android:id="@+id/btn" android:layout_width="80dp" android:layout_height="wrap_content" /> </LinearLayout>
2.方式二。设置 子控件的android:focusable=”false” 属性。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:id="@+id/btn" android:layout_width="80dp" android:focusable="false" android:layout_height="wrap_content" /> </LinearLayout>
总结来说,是事件分发与消费问题。由于时间限制,先列出解决方案。以后完善分析。
相关文章推荐
- 解决Listview的item和里面控件点击事件冲突
- Android ListView的Item点击事件和Item里控件点击事件冲突问题解决
- ListView中item点事件和item中的控件点击事件冲突的简易解决方法
- 关于ListView触摸事件和点击Item事件冲突解决方法
- Listview的item和里面控件点击事件冲突
- ListView点击事件失效(item里面有button按钮控件)解决方法
- Android中ListView或者GridView的Item和Item中控件的事件冲突
- 完美解决listView 文字超链接点击事件和listitem点击事件冲突问题
- ListView触摸事件和Item点击事件冲突解决方法
- ListView 的item中有多个控件导致列表点击事件失效解决
- 我的Android进阶之旅------>Android中ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
- 关于ListView中控件点击事件与Item点击事件冲突的问题
- 关于ListView触摸事件和点击Item事件冲突解决方法
- Android中ListView(gridview)的item中有button等子点击控件时不能响应点击事件的原因
- 关于ListView中控件点击事件与Item点击事件冲突的问题
- ListView中控件点击事件与Item点击事件冲突的问题
- ListView控件的onItemClick事件和item中Button的onClick事件冲突的解决办法
- ListView中的Item点击事件和子控件的冲突或者item点击没有反应的解决办法
- 解决ListView的item监听事件个子控件监听事件冲突问题
- 我的Android进阶之旅------>Android中ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法