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