Android展开式清单检视 [英] Android expandable list view

查看:59
本文介绍了Android展开式清单检视的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在android中创建可扩展列表视图.我希望每个小组都可以扩展到预设的XML布局文件.例如.

Trying to create expandable list view in android. I would like each group to expand to a pre-set XML layout file. For example.

A组 {展开后会显示XML文件A:按钮,搜寻栏,微调框等

Group A { when expanded displays XML file A: buttons, seekbar, spinner and etc }

B组 {展开后显示XML文件B:按钮,搜寻栏,微调框等

Group B { when expanded displays XML file B: buttons, seekbar, spinner and etc }

C组 {展开后显示XML文件C:按钮,搜寻栏,微调框等

Group C { when expanded displays XML file C: buttons, seekbar, spinner and etc }

D组 {展开后显示XML文件D:按钮,搜寻栏,微调框等

Group D { when expanded displays XML file D: buttons, seekbar, spinner and etc }

E组 {展开时显示XML文件E:按钮,搜寻栏,微调框等

Group E { when expanded displays XML file E: buttons, seekbar, spinner and etc }

创建XML文件很简单.如何在所需的组中显示XML文件?

Creating the XML file is simple. How can I display the XML file inside desired group?

推荐答案

如果使用的是BaseExpandableListAdapter,则可以覆盖方法getChildTypeCount()getChildType().然后,您可以在getChildView()中填充匹配的布局,然后参数convertView始终是正确的类型.

If you're using a BaseExpandableListAdapter, you can override the methods getChildTypeCount() and getChildType(). Then you can inflate your matching layout in getChildView(), the parameter convertView will then always be of the correct type.

在您的示例中,getChildTypeCount()将返回5,而getChildType()仅返回groupId.

In your example, getChildTypeCount() would return 5 and getChildType() could simply return the groupId.

这篇关于Android展开式清单检视的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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