Expandable Listview image changes on click?
<p>I have the below code running perfectly. When a user clicks on a group and it expands the image changes due to a change in the state. The xml file is below aswell. The problem I have is when I click on a child element it starts a new activity, but just before you can see that the image changes state to as if the group was closed. When you use the back arrow the image is indeed back to the closed state even though the group is still expanded. Can anyone shed any light on this?</p>

<pre><code>private static final int[] EMPTY_STATE_SET = {};
private static final int[] GROUP_EXPANDED_STATE_SET = {android.R.attr.state_expanded};
private static final int [] [] GROUP_STATE_SETS = {
    EMPTY_STATE_SET, //0
    GROUP_EXPANDED_STATE_SET //1
};

           Cursor groupCursor = checkDB.rawQuery("SELECT * FROM TABLE", null);
            mscta = new MySimpleCursorTreeAdapter(
                                                    this,
                                                    groupCursor,
                                                    R.layout.listGroup,
                                                    new String[] {"group"},
                                                    new int[] {R.id.group},
                                                    R.layout.listChildren,
                                                    new String[] {"child"},
                                                    new int[] {R.id.Child}) {
                @Override
                public View getGroupView (int groupPosition,
                        boolean isExpanded,
                        View convertView,
                        ViewGroup parent) {

                        View v = super.getGroupView( groupPosition, isExpanded, convertView, parent);
                        View ind = v.findViewById(R.id.explist_indicator);
                        if(ind != null){
                            ImageView indicator = (ImageView) ind;
                            indicator.setVisibility( View.VISIBLE );
                            int stateSetIndex = ( isExpanded ? 1:0);
                            Drawable drawable = indicator.getDrawable();
                            drawable.setState(GROUP_STATE_SETS[stateSetIndex]);
                        }
                        return v;
                    }
            };
</code></pre>

<p>XML explist_indicator.xml</p>

<pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item
        android:state_expanded="true"
        android:drawable="@drawable/minus" /&gt;
    &lt;item
        android:drawable="@drawable/plus" /&gt;
&lt;/selector&gt;
</code></pre>
