Android 可扩展列表
我正在尝试将自定义 ExpandableListView
与父级和子级布局以及父级 XML 和子级 XML 结合使用。
我的数据将是服务器响应。因此,我最好希望以数组列表或哈希映射的形式获取父级和子级布局的数据,
我将包含我想要的图像。
有没有办法通过任何 + 或 - UI 表示来更改可扩展列表箭头图像(默认),如下所示。
请针对这种特定情况提出教程或代码逻辑。
I am trying to use a custom ExpandableListView
with parent and child layout with a parent XML and child XML.
My data would be a server response. So I preferably would like to have data in the form of an Array List or Hash-map for parent and child layouts
I am enclosing the images of what I want.
Is there any way to change the expandable list arrow image(Default) by any + or - UI representation as shown below.
Please suggest a tutorial or code logic for this specific situation .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
经过研发后D over Expandable List 我发现expandable List-view是Android提供的一个两级树形视图。
该视图包含两种类型的类别。
第一种类型是Group-Elements,第二种类型是Child-Elements,也称为父元素和子元素。
此示例的主要目的是自定义可扩展列表视图,如问题中的图片所示。
我已经介绍了我在经历中遇到的一些有关可扩展列表视图的重要主题。
下面的代码是 main.xml 包含可扩展的列表视图。
main.xml
group_row.xml 如下,包含可扩展列表组视图的布局structure.group_row.xml
?
child_row.xml 这是包含可扩展列表视图组结构的布局。
child_row.xml
首先从xml读取可扩展列表视图的引用到活动类。
对于自定义 Exp Listview 主要是适配器。 Android 提供了 BaseExpandableListAdapter 用于自定义视图。下面是Adapter的设计代码。
这是用于构造组和子元素的可扩展列表视图的适配器。
group_indicator.xml
这是用于更改默认指示器图像的代码。
After a R & D over expandable List I found that expandable List-view is a two level tree view provided by Android.
This view contains two types of categories.
First type is Group-Elements and second one is Child-Elements, also called parent and child elements.
The main aim of this example is to customize the expandable list-view as the picture in the question shows.
I have covered some important topics about expandable list-view that I faced during my experiences.
Below code is main.xml contains the expandable list-view.
main.xml
the group_row.xml is as follows that contains the layout for Expandable list group view structure.group_row.xml
?
child_row.xml this is contains the layout for Expandable list view group structure.
child_row.xml
First read the reference of the expandable listview from xml to activity class.
For customising the Exp Listview main thing is adapter. Android provides BaseExpandableListAdapter for customising the view. Bellow is the code for design of Adapter.
This is adapter for expandable list-view for constructing the group and child elements.
group_indicator.xml
This the code for changing the default indicator image.
与此同时
我创建了一个selector.xml为:
并在xml中的
android:groupIndicator="@drawable/selector"
中给出 -friend_small 和 placesmall 是我的展开和折叠状态的图像In the meanwhile
I have created an selector.xml as:
and given in
android:groupIndicator="@drawable/selector"
in xml – friend_small and place small are my images of expand and collapsed state您可以通过调用 更改指示器设置组指示符
另外,您需要自己实现 ExpandableListAdapter。可能会在其中夸大自己对父母和孩子的看法。
you can change the indicator by calling setGroupIndicator
also, you need your own implementation of an ExpandableListAdapter. it's possible to inflate your own views for both parents and children in it.