Android-ListView中嵌套(ListView)控件时item的点击事件不起作用的问题
来源:互联网 发布:网络思想政治教育好处 编辑:程序博客网 时间:2024/06/07 00:19
解决:1、在主listview布局文件中的listview中添加属性 android:focusable="false"
2、在子listview中最顶上的布局文件添加属性 android:descendantFocusability="blocksDescendants"
另外,listview嵌套时,主listview的adapter执行一下这行代码,listview的最后一个item才不会异常
adapter.getView(adapter.getCount-1, null,listview);
listview.setAdapter(adapter);
例子如下
主Listview的布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_company_uniqueexhibition"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:background="#FFFFFF"
android:gravity="center_horizontal" >
2、在子listview中最顶上的布局文件添加属性 android:descendantFocusability="blocksDescendants"
另外,listview嵌套时,主listview的adapter执行一下这行代码,listview的最后一个item才不会异常
adapter.getView(adapter.getCount-1, null,listview);
listview.setAdapter(adapter);
例子如下
主Listview的布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_company_uniqueexhibition"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:background="#FFFFFF"
android:gravity="center_horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/head_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="@android:color/transparent"
android:divider="@color/grey"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false"
android:fadingEdge="none"
android:focusable="false"
android:scrollbars="vertical" />
</LinearLayout>
android:id="@+id/head_listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="@android:color/transparent"
android:divider="@color/grey"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false"
android:fadingEdge="none"
android:focusable="false"
android:scrollbars="vertical" />
</LinearLayout>
</RelativeLayout>
》》》》》
listview 嵌套的子listview的布局文件
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="horizontal"
android:descendantFocusability="blocksDescendants"
xmlns:android="http://schemas.android.com/apk/res/android">
》》》》》
listview 嵌套的子listview的布局文件
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:orientation="horizontal"
android:descendantFocusability="blocksDescendants"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@+id/item_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@android:color/transparent"
android:divider="@color/grey"
android:dividerHeight="0dp"
android:drawSelectorOnTop="false"
android:fadingEdge="none"
android:scrollbars="vertical" />
</LinearLayout>
</LinearLayout>
- Android-ListView中嵌套(ListView)控件时item的点击事件不起作用的问题
- ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
- Android 中listview嵌套listview,外面listview的item点击事件失效
- 我的Android进阶之旅------>Android中ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
- Android 解决 ListView的item中嵌套ScrollView,ScrollView拦截ListView的Item点击事件的解决办法
- Android中解决listview的item点击事件和子控件点击事件的冲突
- ListView中控件点击事件与Item点击事件冲突的问题
- 关于ListView中控件点击事件与Item点击事件冲突的问题
- 关于ListView中控件点击事件与Item点击事件冲突的问题
- 关于ListView中控件点击事件与Item点击事件冲突的问题
- Android-ListView中嵌套(ListView)控件时的问题
- Android-ListView中嵌套(ListView)控件时的问题
- Listview嵌套Listview外部item点击事件无效的解决办法
- listView item中子控件的点击事件
- listview item里面的控件点击事件
- Android ListView:实现item内部控件的点击事件
- ListView中每个item条目上控件的点击事件
- Fragment中ListView的Item的点击事件(包含Item内部控件的点击事件)
- 切换动画overridePendingTransition切换无响应的方法
- activity切换时的overridePendingTransition动画效
- 解决Android中TextView首行缩进的问题 .
- ScrollView嵌套ListView只显示一行的问题
- centos6下yum安装lnmp
- Android-ListView中嵌套(ListView)控件时item的点击事件不起作用的问题
- 友善之臂视频监控方案源码学习(1) - 架构分析
- 备份chrome插件---重新加载备份的chrome插件
- listView点击效果不显示
- C语言中怎样判断一个整形数是有符号数还是无符号数
- android让你的TabHost滑动起来
- jquery第八期:两个有关包装集的复杂操作
- 如何使oracle数据库支持zhs16gbk
- java.lang.NoClassDefFoundError: com/opensymphony/xwork2/util/TextUtils