android 联动listview 的一种不太健康的实现方式
来源:互联网 发布:ubuntu解压安装 编辑:程序博客网 时间:2024/05/16 23:55
实现效果:两个listview可以一起上线滑动,其中一个listview左右滑动时,另一个listview不变
布局方式如下,并排放入两个listview并放入一个scrollview中,其中一个listview再放入horizontalscrollview中
布局代码如下
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/LinearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ScrollView android:fillViewport="true" android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="wrap_content" >
<LinearLayout android:layout_width="wrap_content" android:layout_height="446dp" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <ListView android:id="@+id/listView1" android:layout_width="100dp" android:layout_height="wrap_content" > </ListView> <HorizontalScrollView android:id="@+id/horizontalScrollView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" > <ListView android:id="@+id/listView2" android:layout_width="wrap_content" android:layout_height="wrap_content" > </ListView> </HorizontalScrollView> </LinearLayout> </LinearLayout> </ScrollView></LinearLayout>
由于将listview放入scrollview的方法不太健康,所以listview获取的高度会出问题。
需要在更新数据时刷新listview的高度
动态刷新控件高度代码如下
ViewGroup.LayoutParams params = listView.getLayoutParams();params.height=listdata.size()*ListItem.height;listView.setLayoutParams(params);
其中listdata为要设定给listview的数据,listitem为自定义的listitem
- android 联动listview 的一种不太健康的实现方式
- 两个 select 联动的一种实现方式
- Android联动ListView的实现
- Android联动ListView的实现
- scrollview嵌套listview的一种实现方式
- 十一种健康的吃饭方式
- 联动Listview(实现真正的联动效果)
- Android ListView嵌套ListView的实现方式
- Android ListView嵌套ListView的实现方式
- TabLayout android Tab的一种实现方式
- 不太完整的dropdownlist三级联动查询
- android中一种不常见的函数调用方式
- listview notifydatasetchanged 不刷新的一种解释
- Android ListView优化的另一种实现方式
- listview效率最高的一种方式
- 一种不太完善的OpenStreetMap字典汉化方法
- Jquery-select-处理二级联动的一种简单方式
- PIP下载太慢的一种解决方式
- 字符编码
- 编程之美--N的阶乘中末尾有几个0
- calloc(), malloc(), realloc(), free(),alloca()
- Linux开启FTP(vsftpd)服务
- 程序员老鸟写sql语句的经验之谈【转】
- android 联动listview 的一种不太健康的实现方式
- 64位系统 使用 flash player debug 调试
- od命令使用
- 字符编码·ISO8859
- 配置django连接SQL Server 2005遇到的问题解决
- c#委托Action和Func
- table 里面的 checkbox 全选,取消,单选,选中一行后选中行高亮
- 仿淘宝图片放大预览效果
- 【初学servlet】Servlet基础知识