How can I programmatically display a ViewFlipper's second child?

Sheehan Alam picture Sheehan Alam · Sep 9, 2010 · Viewed 14.8k times · Source

I have a ViewFlipper with 3 children.

I want to be able to display any of these children initially. So for example, maybe I want the ViewFlipper to load initially with the 2nd child and not the 1st.

EDIT: I know I can use the getChildAt(int index) method.

When a child in a ViewFlipper is shown, how can I get that child's index?

Answer

CommonsWare picture CommonsWare · Sep 9, 2010

I want to be able to display any of these children initially. So for example, maybe I want the ViewFlipper to load initially with the 2nd child and not the 1st.

Call setDisplayedChild().

When a child in a ViewFlipper is shown, how can I get that child's index?

Call getDisplayedChild().