ListView 显示问题 如题 我现在想要显示很多行信息 现在框里只能显示2行 旁边有个垂直的滚动条 我不想这样 想直接全显示出来 应该如何做 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我也遇到过这样的问题,我的做法是当ListView中的行数变化时,手动设置ListView的高度,代码如下:/** * 设置列表框高度,解决滚屏问题 */ private void initListViewHeight(){ ArrayAdapter<String> listAdapter = (ArrayAdapter<String>)listPhone.getAdapter(); if (listAdapter == null) { return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listPhone); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listPhone.getLayoutParams(); params.height = totalHeight + (listPhone.getDividerHeight() * (listAdapter.getCount() - 1)); params.height += 5; listPhone.setLayoutParams(params); } 是不是和SCrollView套用了?重写listview的getView,楼主搜索一下就出来了。 解决Android布局中ScrollView与ListView的冲突解决的办法有2个 :1.在ScrollView中添加一属性 android:fillViewport="true" ,这样就可以让ListView全屏显示了 ;2.指定ListView的高度 android:layout_height="420dp" ; 在eclipse中安装了安卓模拟器、模拟器中的照相机为什么不能偷打开电脑的摄像头 求教为什么service接受到的值是空? 如何引用一个静态数组里边的值 android 版本升级 这个布局属性该如何设置? 一个Fragment中的listview 更新另一个fragment中的 listview android 视频录制 以及压缩 mp4 我是不是想的不对? cmd java [求助]如何后台获取STK弹出的窗口内的文字 关于SurfaceView创建时,surfaceCreated调用的问题 急~~音乐名字显示乱码 关于 Activity.managedQuery的疑问
/**
* 设置列表框高度,解决滚屏问题
*/
private void initListViewHeight(){
ArrayAdapter<String> listAdapter = (ArrayAdapter<String>)listPhone.getAdapter();
if (listAdapter == null) {
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listPhone);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listPhone.getLayoutParams();
params.height = totalHeight + (listPhone.getDividerHeight() * (listAdapter.getCount() - 1));
params.height += 5;
listPhone.setLayoutParams(params);
}
1.在ScrollView中添加一属性 android:fillViewport="true" ,这样就可以让ListView全屏显示了 ;
2.指定ListView的高度 android:layout_height="420dp" ;