Android的,怎样的ListView项目分为三部分? [英] Android, How to split ListView items into three parts?

查看:410
本文介绍了Android的,怎样的ListView项目分为三部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的活动,我有三个列表,每个列表中有三个项目。测试这种方式后(请参见:<一href=\"http://stackoverflow.com/questions/10496804/android-how-to-add-scrollview-into-screen-which-has-some-list-items/10497011#10497011\">Android,如何添加滚动型为屏幕里面有一些列表项?),我发现它不可能滚动屏幕,同时你有一些列出的活动。另外,我发现这个答案(<一个href=\"http://stackoverflow.com/questions/6404413/add-multiple-listview-in-one-activity?answertab=votes#tab-top\">add在一个活动多个列表视图),它划分屏幕分为三段,所以我没有足够的空间来显示所有项目和屏幕不滚动的为好。

In my activity, i have three lists and each list has three items. After testing this way (please see: Android, How to add ScrollView into screen which has some list items?), i found that its impossible to scroll screen while you have some lists in an activity. Also, I found this answer (add multiple listview in one activity) which divided the screen into three segments therefore, i didn't have enough space to show all items and screen was not scrollable as well.

一个人傻傻的解决方案是为每个项目创建的XML并把它放在活动的XML布局。虽然它的工作原理,但我必须复制/粘贴code那么多行。

one silly solution is to create xml for each item and put it in xml layout of activity. Although it works but i have to copy/paste so many lines of code.

更好的方法是使用适配器,所以,在我的下一个尝试,我可以在其他两个列表的结果加入到我的第一个列表,然后结果发送到适配器类。因此,适配器会显示在列表中的所有项目。虽然,它解决了我的问题紧靠屏幕滚动(在屏幕列表的滚动=这一次滚动),但我需要在每三个项目的顶部,有头。

Better way is using adapter, so, in my next try, i can add the result of two other lists into my first list and then send the result to adapter class. Therefore, adapter will show all items in the list. Although, it solves my problem abut scrolling of screen (at this time scroll of screen = scroll of list), but I need to have header at top of each three items.

是否有可能告诉适配器添加例如header.xml,每三个项目名单后?

Is it possible to tell adapter to add for example header.xml, after each three items of list?

希望能解释清楚!谢谢

推荐答案

寻找切片ListView控件可以在下面一些有用的链接网站

Look for sectioned ListView you can find many exemple on the web below some useful links

第一个环节

二环线

如果你想与3类这样的可扩展列表视图

if you want an expandable list view with 3 categories like this

看到这个链接三链接源$ C ​​$ C连接到它

see this link Third Link the source code is attached to it

这篇关于Android的,怎样的ListView项目分为三部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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