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

泪湿孤枕 提交于 2019-12-08 15:13:41

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/3678458/how-can-i-programmatically-display-a-viewflippers-second-child

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!