Android Expandablelistview implements multiple groups of lists, similar to QQ grouping

Source: Internet
Author: User

First Straight,

1:, Unfolded:





2: The following is the click Contraction.


3: Here is the code section:

We're going to define 2 sets to store the data, one for the Groupitem data, one for the ChildItem data.

Private list<map<string, object>> grouplist = new arraylist<map<string, object>> ();//Group name
Public list<list<map<string, object>>> childlist = new arraylist<list<map<string, Object >>> ();//Detailed name


Define a control:

Public Expandablelistview Expandablelistview; 2-tier List

Fill in the data we get to the inside:

adapter = new Jingcaizuqiuwinbeatlotteryadapter (Mainactivity.this, Winbeatlotterymain, Grouplist, childList);
Expandablelistview.setadapter (adapter);
Expandablelistview.setgroupindicator (null);//Remove the default arrow for Group control


Group expansion
Expandablelistview.setongroupexpandlistener (New Ongroupexpandlistener () {
public void Ongroupexpand (int groupposition) {
Expandablelistview.expandgroup (groupposition);
}
});
Group off
Expandablelistview.setongroupcollapselistener (New Ongroupcollapselistener () {
public void ongroupcollapse (int groupposition) {
Expandablelistview.collapsegroup (groupposition);
}
});
subkey Click
/*
* Expandablelistview.setonchildclicklistener (New Onchildclicklistener ()
* {public boolean Onchildclick (Expandablelistview arg0, View arg1, int
* groupposition, int childposition, long Arg4) {return false;}});
*/

Expand All, Default
int groupcount = Expandablelistview.getcount ();
for (int i = 0; i < GroupCount; i++) {
Expandablelistview.expandgroup (i);
}


Actually very simple, here I enclose a small demo of my source code. There are notes inside. There are downloads in my resources. I'll give you a link later.




Android Expandablelistview implements multiple groups of lists, similar to QQ grouping

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.