title: ExpandableListView - collapse groups automatically
body: <p>I created an ExpandableListView with a custom adapter and all works perfectly including the click, collapse and expand events. If anyone needs assistance with the expandable listview I followed the tutorial at: <a href="http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/" rel="nofollow noreferrer">http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/</a>.</p>
  
  <p>I now want to write code in my setOnGroupExpandListener method to collapse all other Groups that are open apart from the one that is currently focussed. (Content aware - in a sense) To clarify, if I have the following:</p>
  
  <p>Item 1</p>
  
  <ul>
  <li>Sub Item 1</li>
  <li>Sub Item 2</li>
  </ul>
  
  <p>Item 2</p>
  
  <ul>
  <li>Sub Item 1</li>
  </ul>
  
  <p>Item 3</p>
  
  <ul>
  <li>Sub Item 1</li>
  <li>Sub Item 2</li>
  </ul>
  
  <p>If I click on Item 1, it should expand Item 1 (this already works) and it should collapse Item 2 and Item 3 groups for me. Is this possible and how can I achieve that?</p>
  
  <p>Here is my current setOnGroupExpandListener:</p>
  
  <pre><code>    gpsMenuListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
          @Override
          public void onGroupExpand(int groupPosition) {
              Toast.makeText(getApplicationContext(), "Expanded: " + gpsMenuListDataHeader.get(groupPosition).toString(), Toast.LENGTH_SHORT).show();
          }
      });
  </code></pre>
  
  <p>As you can see I currently only have a Toast that prints a message but I want to add the collapse functionality.</p>