3

I've been trying to figure this out for days now, after searching and searching and searching I gave up and decided to ask the community. Any help is greatly appreciated. I am extending BaseExpandableListAdapter and using the Lazy Image Loading technique to parse svg graphics into drawables and set those drawables as children of my expandable list. Everything works perfect.

The expandable list is generated and is in a collapsed state while the svgs are beings parsed and loaded in the background. If the user expands a group and the children haven't finished loading then a simple "Loading..." message is displayed. As soon as any one of the AsyncTasks finish and fire off onPostExecute the expandable list view is updated with another drawable and any expanded groups reset back to a collapsed state.

Problem: I can't figure out how save the expanded/collapsed states of groups so they wouldn't get reset when AsyncTasks update my list. It seems when explicitly calling onContentChangedExtended() the whole list is reset back to its initial state, while, when an Activity implicitly updates the view it saves the expanded/collapsed states. How does it do it?

And forcing all the groups to be expanded initially is not an option because it beats the whole purpose of an expandable list.

public class ListAdapter<T> extends BaseExpandableListAdapter {
  // Some implementation here.
}

This is the child object that populates the groups:

public class Expression {
  /* Some implementation here.
   * .
   * .
   * .
   */

  // ListViewGenerator extends ExpandableListActivity
  private class ParseSVG extends AsyncTask<ListViewGenerator, Void, ListViewGenerator> {
    /* Parse svg in background.
     * .
     * .
     * .
     */
    @Override
    protected void onPostExecute(ListViewGenerator listView)
      {listView.onContentChangedExtended();}
  }
}

I've tried saving the isExpanded inside getGroupView() to a boolean array and try to restore the expand/collapse state from ExpandableListActivity with no luck, as soon as onContentChangedExtended() is called, the getGroupView() is already reset back to a collapsed state so my array is cleared and set to "collapsed"...

Thank you in advance!

Oleg
  • 348
  • 2
  • 11

0 Answers0