如何在 Viewflipper 中设置 onclick 监听器
无论如何,有没有在翻转视图中设置 onlickListener 。在我的应用程序中,有一个带有“下一步”、“上一个”和“完成”按钮的问题向导。我已经用ViewFlipper翻阅了所有的问题。 Flipper 中的每个视图都有一个文本视图和 4 个单选按钮包裹在 Radiogroup 内。我想获取当用户单击完成按钮时选择的 RadioButton 的值。我计划做的是,每次单击单选按钮时调用一个函数将值存储在数组中,并在单击完成按钮时获取该数组。有什么建议如何建立这个吗!
我的问题向导将如下所示:
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 establish this!
My Question wizard will look like this:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
冒着鼓励过早优化的风险,我解决了一个与此非常相似的问题(翻转一组可能有几十个或多或少相同的页面),结果非常好,并且可以解决您的问题,尽管稍微间接。
我的技术的基础是拥有一个包含单个子页面的
ViewFlipper
。当用户单击“上一个”或“下一个”时,会发生以下情况:我需要付出额外的努力,因为我的页面非常复杂......几个列表、各种按钮、图像等。在我的视图层次结构中包含 2 或 3 个它们将是非常浪费的,更不用说几十个了。上述技术最大限度地减少了布局的复杂性,如果页面很复杂,翻转动画的运行速度会更快。
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: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.