Expandablelistview asynchronous expansion/load children

Source: Internet
Author: User


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.



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.