ScrollView嵌套ListView解决办法
来源:互联网 发布:sar算法平台 编辑:程序博客网 时间:2024/06/13 02:00
public class ListViewRelayout {public void setListViewHeightBasedOnChildren(ListView listView) {// get the list view adapter, so this function must be invoked after set the adapter.ListAdapter listAdapter = listView.getAdapter();if (listAdapter == null) {return;}int totalHeight = 0;// get the ListView countint count = listAdapter.getCount();for (int i = 0; i < count; i++) {View listItem = listAdapter.getView(i, null, listView);// measure the child viewlistItem.measure(0, 0);// calculate the total height of itemstotalHeight += listItem.getMeasuredHeight();}ViewGroup.LayoutParams params = listView.getLayoutParams();// get divider height for all items and add the total heightparams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));listView.setLayoutParams(params); }}
2、在ListActivity.java mAppListView.setAdapter(mAppListAdapter); mRelayout.setListViewHeightBasedOnChildren(mAppListView);
如果你还增加了对ListView的动态改变,那么,还需要在notifyDataSetChanged后再调用一次,如:
mEnableAppListAdapter.notifyDataSetChanged(); mUtil.setListViewHeightBasedOnChildren(mEnableAppListView);
0 0
- ScrollView嵌套ListView解决办法
- ScrollView嵌套ListView解决办法
- ScrollView嵌套ListView的解决办法
- ScrollView嵌套GridView、ListView的解决办法
- ScrollView嵌套GridView、ListView的解决办法
- ScrollView嵌套GridView、ListView的解决办法
- ScrollView嵌套GridView、ListView的解决办法
- ScrollView中嵌套ListView的解决办法整理
- Android ScrollView嵌套 ListView/GridView 解决办法
- ScrollView嵌套GridView、ListView的解决办法
- ScrollView里嵌套ListView的解决办法。
- ScrollView嵌套listView显示一条item解决办法
- ScrollView嵌套listView显示不全解决办法
- ScrollView嵌套ListView数据显示不完全解决办法
- android-ScrollView嵌套ListView冲突解决办法
- ScrollView嵌套listView,嵌套Gridview显示不全的解决办法
- ScrollView嵌套ListView显示不完全、嵌套TextView不能滚动解决办法
- ScrollView嵌套ListView显示不完全、嵌套TextView不能滚动解决办法
- 陈力:传智播客古代 珍宝币 泡泡龙游戏开发第32讲:PHP 构造方法、析构方法
- 浅谈Shiro框架中的加密算法,以及校验
- ContentProvider(实现增生改查)(3)
- crontab 使用注意及处理No Space问题
- Java集合框架新特性
- ScrollView嵌套ListView解决办法
- django安装异常
- 获取线程池的方法 ExecutorService
- 陈力:传智播客古代 珍宝币 泡泡龙游戏开发第33讲:PHP 静态变量、静态方法
- Openstack nova代码部分注释一
- android studio 使用gradle批量打渠道包
- IAR编译ZStack-CC2530,生成HEX文件完全配置
- hdoj-3787-A+B(小坑)
- Fragment(二)Android手机平板两不误,使用Fragment实现兼容手机和平板的程序