I have a ViewFlipper implementation that needs to be improved. This ViewFlipper has three child views. Basically, I want an indicator on which child view is currently active
I know this question already has an answer. But here's an alternative which is a method ViewFlipper
inherited from ViewGroup
and which seems to be the best from my experience.
Code Snippets Below:
ViewFlipper viewFlipper = findViewById (R.id.myViewFlipperId);
viewFlipper.setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener);
The onChildViewAdded(View, View)
method in the callback listener will be invoked whenever a child view is added to the ViewGroup
.
Which you can use to detect whenever the ViewFlipper
flips.
See ViewGroup.html#setOnHierarchyChangeListener API Docs