title: Updating Expandable ListView after sorting the items
body: <p><strong>Overview:</strong></p>
  
  <ul>
  <li>I have an Expandable List View which displays items of the type <code>ToDoElement</code>.</li>
  <li>Each <code>ToDoElement</code> item has one String for the Group-Element and 1-3 Strings for the Child-Elements</li>
  <li>My custom List Adapter <code>expListAdapter</code> gets the informations about the group- and child-items with the methods <code>createGroupList()</code> and <code>createChildList()</code>.</li>
  <li>In the Method <code>createChildList()</code> i check how many Strings for the child-items are in the <code>ToDoElement</code> and create the child-items for the Adapter.</li>
  <li>At the end I can sort my list by comparing the Strings for the group-items.</li>
  </ul>
  
  <p>All of this works fine, but here is my <strong>Problem:</strong></p>
  
  <ul>
  <li>After the items in the List View are sorted correctly, the number of child-items is wrong.</li>
  <li>That's because my List Adapter doesn't know that the number of child-items has changed. So some child-items aren't displayed and other child-items are just empty, because there is no data for them.</li>
  </ul>
  
  <p>My <strong>Suggestion:</strong></p>
  
  <p>I know that somehow the methods <code>createGroupList()</code> and <code>createChildList()</code> have to be called again from my Adapter, but i don't know how to do it. <br>I've tried <code>expListAdapter.notifyDataSetInvalidated()</code>, because somebody told me that this method would call <code>createGroupList()</code> and <code>createChildList()</code> again, but is doesn't work.</p>
  
  <p><strong>Code Fragments:</strong></p>
  
  <p>Definition of my List Adapter:</p>
  
  <pre><code>expListAdapter = new MyListAdapter(this, createGroupList(), createGroupList());
  setListAdapter( expListAdapter );
  </code></pre>
  
  <p>createGroupList() and createChildList():</p>
  
  <pre><code>    private List createGroupList() {    
        ArrayList result = new ArrayList();
        for (int i=0; i &lt; Liste.AnzahlElemente(); i++) {    //
          result.add(Liste.getSize(i).getGroupString());
        }
        return result;
      }
  
      private List createChildList() {
          ArrayList result = new ArrayList();
          for(int i=0; i &lt; Liste.getSize(); i++) {
              ArrayList secList = new ArrayList();
              for( int n = 1 ; n &lt;= 3 ; n++ ) {
                  if (Liste.getElement(i).getChildString(n).length() != 0){
                      secList.add( "- " + Liste.getElement(i).getChildString(n));
                  }
              }
              result.add( secList );
          }
          return result;
  }
  </code></pre>
  
  <p>Sorting the List:
  <br>(<code>Liste</code> is an <code>ToDoListe</code> object, which manages the <code>ToDoElement</code>s in an Array List)</p>
  
  <pre><code>Collections.sort(Liste.getListe(), new NameComparator());
  
  expListAdapter.notifyDataSetInvalidated();
  
  //expListAdapter.notifyDataSetChanged(); //same effect as notifyDataSetInvalided
  </code></pre>
  
  <p>my NameComparator:</p>
  
  <pre><code>public class NameComparator implements Comparator&lt;ToDoElement&gt;{
  
       public int compare(ToDoElement item1, ToDoElement item2) {
             return item1.getGroupString().compareTo(item2.getGroupString());
       }
  }
  </code></pre>
  
  <p><br>Thanks a lot for your help!!</p>