Android expandablelistview expand list control usage instance

Do you think the control of friends list on mobile QQ is very good? No... that doesn't matter. Learning more knowledge is beneficial and harmless to yourself.

Then let's start.

The expanded list control, formerly called expandablelistview, is an advanced version of an ordinary list control. It can shrink the list freely, which is very convenient and good-looking. First look at the screenshot I completed. Although the interface is not beautiful, you can modify the interface yourself.

The control needs a main interface XML, a title interface XML and a list content interface XML. First, let's take a look at the main interface of mian.xml

Groups.xml this interface is the parent Title interface. We just need to put a title textview control to be displayed

Children.xml is a child control that directly displays the contents of the list

Next, go to the main code. The naming is a little messy. Don't name it like this when you really use it for development

Finally, run your simulator and you can see it. Control the expandablelistview above. It is relatively simple. We just need to use the ordinary activity class instead of inheriting expandablelistview. Just add private expandablelistview expandlist in the member variable; Then change to expandlist. Setadapter (Sela) when adding content; That's it. Of course, the response event listener can also be added by itself.

Attachment: another example

The usage of expandablelistview is similar to listview, GridView and gallery. Both are displayed through an adapter. Main.xml:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>