Viewflipper listener for when next view is actually displayed
<p>I have 2 ExpandableListViews and I'm using a ViewFlipper to switch between them using a fling action. My flipper layout looks something like this</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"&gt;
    &lt;ViewFlipper 
        android:id="@+id/flipper" 
        android:layout_width="fill_parent"      
        android:layout_height="fill_parent"&gt;
        &lt;LinearLayout 
            android:id="@+id/view1"
            android:orientation="vertical"&gt;
            &lt;ExpandableListView 
                android:id="@id/android:list"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:drawSelectorOnTop="false"/&gt;
            &lt;ImageView
                android:id="@id/android:empty"
                android:src="@drawable/logo"&gt;
           &lt;/ImageView&gt;
        &lt;/LinearLayout&gt;
        &lt;LinearLayout 
            android:id="@+id/view2"
            android:orientation="vertical"&gt;
            &lt;ExpandableListView 
                android:id="@id/android:list"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:drawSelectorOnTop="false"/&gt;
            &lt;ImageView
                android:id="@id/android:empty"
                android:src="@drawable/logo"&gt;
           &lt;/ImageView&gt;
        &lt;/LinearLayout&gt;
    &lt;/ViewFlipper&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>I want to automatically expand the first group in the list whenever the view is switched to
so I switch to the next view and then I expand the first group if the view has any groups present. Something like this</p>

<pre><code>public void switchNextView(){
    flipper.showNext();
    expandFirstGroup();       
}

public void expandFirstGroup(){
    LinearLayout layout = (LinearLayout)flipper.getCurrentView();
    ExpandableListView view = (ExpandableListView)layout.getChildAt(0);

    if(view.getChildCount() &gt; 0){
        view.expandGroup(0);
    }
}
</code></pre>

<p>Now the problem is that getChildCount() always returns 0 the first time I'm switching to the next view which tells me that the the groups have still not been added to the ExpandableListView at this point</p>

<p>In order to decide when the view was actually 'ready' I created an AnimationListener and called expandFirstGroup() in the onAnimationEnd()</p>

<p>This seemed to be a workaround though since I might not always have/need an animation so my question is are there any better ways of doing this i.e. finding when the view is displayed or ready to be displayed?</p>
