How to set onclick listener inside Viewflipper
Is there anyway to set onlickListener inside a flipper view. In my application, there is a question wizard with "Next","Previous" and "Finish" button. I have used the ViewFlipper to flip through all the questions. There is having a textview and 4 radiobuttons wrapped inside a Radiogroup for each view in flipper. I want to get the value of the RadioButton selected when users click the finish button. What I have planned to do is, call a function to store the value in an array each time when the radio button is clicked and get the array when clicking on the finish button. Is there any suggestion how to establ开发者_高级运维ish this!
My Question wizard will look like this:
At the risk of encouraging premature optimization, I've solved a problem very similar to this (flipping a set of potentially dozens of more or less identical pages) which turned out quite nicely, and which would solve your problem albeit slightly indirectly.
The basis of my technique was to have a ViewFlipper
containing a single child page. When the user clicked 'previous' or 'next' the following things would happen:
- Instantiate a special View which 'clones' an image of the ViewFlipper's real child view.
- Add the clone View to the ViewFlipper and set it as the current child without any animation. So far the UI looks as if nothing has changed.
- Update the real child view (now obscured by the clone) with the text and images etc for the page being flipped in.
- Set the ViewFlipper's current page back to its real child view, this time with a nice animation.
I needed to go this extra mile because my page was very complex... several lists, all sorts of buttons, images etc. It would have been terribly wasteful to have 2 or 3 of them in my view hierarchy, let alone dozens. The above technique minimizes your layout complexity, and the flipping animation gets to run a lot faster if the page is complex.
精彩评论