title: Android ExpandableListView scroll group content into view
body: <p>I am trying to implement an ExpandableListView in Android that exhibits accordion type behavior (only one group can be open at a time).  It is pretty simple to add code in the setOnGroupExpandListener to collapse one group when another is opened (see below).</p>
  
  <pre><code>getExpandableListView().setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
      @Override
      public void onGroupExpand(int groupPosition) {
          if (lastExpandedChapter != -1
                  &amp;&amp; groupPosition != lastExpandedChapter) {
              getExpandableListView().collapseGroup(lastExpandedChapter);
          }
          lastExpandedChapter = groupPosition;
      }
  });
  </code></pre>
  
  <p>However, I've noticed that this seems to confuse the default scrolling logic in the ExpandableListView.  When expanding a group, the default scroll will ensure the group's content is viewable (scrolling down as necessary to view it).  This is essentially what I want.</p>
  
  <p>When I add code to automatically collapse the previously opened group when a new one is expanded, the scroll gets a little wonky if the group being opened is below the one that is programmatically closed.  The list view is scrolled too far up.  It works fine if I click to close the groups, but when I do it programmatically in the handler, the scrolling is off.</p>
  
  <p>Any suggestions how to either (A) change the automatic collapse code so it doesn't confuse the default scroll or (B) programmatically adjust the scroll of the list view to the correct location?</p>