Android中一个Activity两个ListView的显示错误问题
来源:互联网 发布:win7如何设置网络类型 编辑:程序博客网 时间:2024/05/01 15:37
我想要在一个Activity中显示两个列表控件(Activity绑定的layout中有两个ListView组件)如:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/bg"> <!-- start --> <ListView android:id="@+id/lstfirst" android:layout_width="fill_parent" android:layout_height="fill_parent“/> <!-- end --> <ListView android:id="@+id/lstReplys" android:layout_width="fill_parent" android:layout_height="fill_parent"/></RelativeLayout>
然后对每个ListView组件从服务器端获取数据并进行数据绑定之后,但是只能显示第一个ListView组件的内容,即使第二个ListView组件的高度高于第一个ListView也只显示第一个ListView组件的内容,就好像系统忽略了第二个ListView组件。
解决方法:在俩个ListView组件之间添加margin-top属性:
<ListView android:id="@+id/lstfirst" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginTop="50px"/> <!-- end --> <ListView android:id="@+id/lstReplys" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginTop="160px"/>
如android:layout_marginTop=”50px”之后就可以显示出俩个ListView组件内容了
还有一个问题:就是到底是多少px合适呢?试过其它数值但都有一个问题就是2个ListView不能很好的融合,也就是2个组件之前缺少一个灰色横线,但如果用50px的话,2个ListView之间就会出现一个灰色横线,这样就会看起来仿佛是一个ListView的效果(这也正是楼主想要的效果)
0 0
- Android中一个Activity两个ListView的显示错误问题
- android ListView中item中两个重叠view,一个显示另一个隐藏的方法
- Activity中一个监听器监听两个listView
- Android 一个页面上下两个ListView的页面显示
- Android 在一个Activity的一部分中显示其他Activity
- Android-关于一个界面同级中需要两个listView时,一个ListView被嵌套在ScrollView中,ListView的适配器adapter中的getView执行次数重复问题
- 在一个Activity中两个llistView共存的问题
- Android ListView 4 一个页面显示两个ListView
- android ListView中只显示一个item问题的两种解决办法
- Android 关于在ScrollView中加上一个ListView,ListView内容显示不完全(总是显示第一项)的问题的两种简单的解决方案
- Android在ListView中嵌套ListView 解决嵌套的listview显示不全的问题
- Android中ListView的addFooterView不显示的问题
- Android中ListView的addFooterView不显示的问题
- Android中ListView的addFooterView不显示的问题
- Android中ListView的addFooterView不显示的问题
- Android中ListView的addFooterView不显示的问题
- Android中ListView的addFooterView不显示的有关问题
- android scrollview listview 嵌套, 显示时总是显示listview内容,没有显示到activity顶部问题
- Redis各种数据结构(类型)的简要区别
- java.io.NotSerializableException错误解决方法
- 一起talk GCC吧(第六回:GCC调试)
- Jquery的个人学习笔记
- android中控件ToggleButton开关控件
- Android中一个Activity两个ListView的显示错误问题
- 将数据导出到Excel(java操作Excel)
- 程序员的学习方法【思考】
- TCL脚本语言学习
- assert()函数用法总结
- LeetCode Subsets II
- 第17周周三
- 一些有用的网站
- 基于android开发手机控制空调的程序(硬件+软件)