如何在 Viewflipper 中设置 onclick 监听器

发布于 2024-10-06 19:42:32 字数 330 浏览 4 评论 0原文

无论如何,有没有在翻转视图中设置 onlickListener 。在我的应用程序中,有一个带有“下一步”、“上一个”和“完成”按钮的问题向导。我已经用ViewFlipper翻阅了所有的问题。 Flipper 中的每个视图都有一个文本视图和 4 个单选按钮包裹在 Radiogroup 内。我想获取当用户单击完成按钮时选择的 RadioButton 的值。我计划做的是,每次单击单选按钮时调用一个函数将值存储在数组中,并在单击完成按钮时获取该数组。有什么建议如何建立这个吗!

我的问题向导将如下所示:

alt text

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:

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世俗缘 2024-10-13 19:42:32

冒着鼓励过早优化的风险,我解决了一个与此非常相似的问题(翻转一组可能有几十个或多或少相同的页面),结果非常好,并且可以解决您的问题,尽管稍微间接。

我的技术的基础是拥有一个包含单个子页面的ViewFlipper。当用户单击“上一个”或“下一个”时,会发生以下情况:

  • 实例化一个特殊的视图,该视图“克隆”ViewFlipper 的真实子视图的图像。
  • 将克隆 View 添加到 ViewFlipper 并将其设置为当前子视图,不带任何动画。到目前为止,用户界面看起来好像没有任何变化。
  • 使用要翻转的页面的文本和图像等更新真实的子视图(现在被克隆遮挡)。
  • 将 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:

  • 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文