14

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?

Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556

2 Answers2

22

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().

Jyotman Singh
  • 10,792
  • 8
  • 39
  • 55
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • `setDisplayedChild()` does not work good with `setInAnimation()`. If animation is added, ViewFlipper does not hide other items than which is shown, all views are put on top of each other – Jemshit Aug 22 '16 at 08:08
12

bringChildToFront(child) does nothing but changes the index value of the child.

In order to bring a child to the front without using showNext() or showprevious(),

use

setDisplayedChild() and indexOfChild() together.

example

vf.setDisplayedChild(vf.indexOfChild(child));

where child is the view that needs to be brought front.

Thanks

sm abbas
  • 1,008
  • 12
  • 13