我想滚动的ListView 2在布局 [英] I want to scroll two ListView in a layout

查看:131
本文介绍了我想滚动的ListView 2在布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在布局中有2个的ListView 。我希望每个的ListView 显示自己的所有项目。和滚动整个布局。

I have 2 ListView in a layout. I want each ListView show all their items. And scroll the whole layout.

推荐答案

从GoogleIO ListView控件的开发人员之一的答案是:不要把一个ListView的滚动型。这意味着如果你想为你正在尝试做的,你也许并不需要一个ListView在所有未滚动一个ListView。

A answer from one of the ListView Developers from the GoogleIO is: Never put a ListView in a ScrollView. This means if you want a ListView that is not scrolling as you are trying to do you maybe don't need a listview at all.

您可以创建一个ListView放的LinearLayout中,并使用适配器从两个列表视图,通过手动添加列表中的项目<一个href=\"http://developer.android.com/reference/android/view/ViewGroup.html#addView%28android.view.View%29\"相对=nofollow> linearlayout.addView 现在你有一个包含列表的所有项目之一滚动视图。因为没有回收和项目的仅加载列表中,这是非常低效的,只有可用的,如果你没有那么多的项目。

You could create a ListView put a Linearlayout in it and use the Adapters from the two Listviews to manually add the items of the list via linearlayout.addView Now you have one scrollable view that contains all items of the list. Because there is no recycling and only loading of the items in the list this is very inefficient and only usable if you don't have that much items.

,你可以去,如果你有第二个更复杂的方式说,在每个列表20个项目是使用自定义的适配器,需要两个listadapters,让你把所有的项目在一个列表。

The second more complicated way that you can go if you have say 20 items in each list is to use a custom adapter that takes the two listadapters and let you put all the items in one list.

这篇关于我想滚动的ListView 2在布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆