Expandablelistview Asynchronous expansion/load children
Level Two list is a more commonly used control, the group list is generally at the beginning of the acquisition, but the sub-list under the group is still to be obtained through the network request, so, it is better to use asynchronous, and how to deal with the interface, the landlord is using this way:
1.setup a expandablelistview,group of data is loaded at the beginning of the degree.
2. We set up for Expandablelistview
[Java] view plain copy mlist.setongroupclicklistener (this);
The contents of which are written like this
[Java] view plain copy @Override public boolean Ongroupclick (expandablelistview parent, view v, int groupposit ion, Long ID) {Boolean expanded = parent.isgroupexpanded (groupposition); if (!expanded) {//In this load data, it is recommended to use Asycntask and the like in another thread to return true; } return false; }
3. After the data is requested in another thread (the landlord uses Asynctask)
[Java] View Plain Copy private class asyncgetchanneltask extends asynctask<object, void, integer> { @Override protected integer doinbackground (Object ... params) { // Request data from the network return result; } @Override protected void onpostexecute (integer res) { // ok, there is data now, can expand &nBsp; mlist.expandgroup (grouppos); } }
4. In this way we want the asynchronous loading effect is reached, the landlord on three pictures to show.