使用代码访问通过 LWUIT 资源编辑器创建的表单

发布于 2024-12-23 02:17:39 字数 813 浏览 2 评论 0原文

我正在尝试使用 LWUIT 资源编辑器开发一个测验应用程序,但遇到了很大的困难。

我创建了两个 Forms 'GUI1' 和 'GUI2' 。

GUI1 显示以下内容:

  1. 一个问题(以 TextField 的形式)
  2. 属于同一组的 5 个 RadioButtons
  3. 一个显示“OK”的 Button

GUI2 显示以下内容:

  1. 一个 TextField
  2. 一个返回 GUI1 的 Button

现在问题是:

最初显示 GUI1。当用户选择 RadioButton 时,我想知道选择了哪个 RadioButton 。如果该 RadioButton 确实是正确答案,那么当用户单击 GUI1 上的“确定”Button 时,我希望在 中显示文本“正确” GUI2 上的 >TextField,然后显示 GUI2。

如果用户选择了错误的答案,那么我希望在 GUI2 上的 TextField 中显示文本“错误”,然后显示 GUI2。

如何使用资源编辑器来完成此操作?我很狡猾。请帮忙。 当我当前使用 GUI1 时,我希望引用 GUI2 上的 TextField。如何使用资源编辑器来完成此操作?为所有这些编写手动代码将非常耗时。

I am trying to develop a quiz application using LWUIT resource editor and am having great difficulty.

I have created two Forms 'GUI1' and 'GUI2' .

GUI1 displays the following:

  1. A question(in the form of a TextField)
  2. 5 RadioButtons belonging to the same group
  3. A Button which says 'OK'

GUI2 displays the following:

  1. A TextField
  2. A Button to go back to GUI1

Now the problem is:

Initially GUI1 is displayed. When the user chooses a RadioButton , I wish to know which RadioButton was selected. If that RadioButton was indeed the correct answer, then when the user clicks on the 'OK' Button on GUI1, I wish to display the text 'correct' in the TextField on GUI2 and then display the GUI2.

If the user chose the wrong answer, then I wish to display the text "Wrong" in the TextField on GUI2 and then display the GUI2.

How can this be done with resource editor? I am very foxed. Please help.
I wish to refer to the TextField on GUI2 when I am currently on GUI1. How can this be done with resource editor? Writing a manual code for all this would be very time consuming.

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

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

发布评论

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

评论(2

喜爱纠缠 2024-12-30 02:17:39

好的,我会尽力解释。

当您设计第一个 Form GUI1 时,五个 RadioButton 必须位于同一组中。我不知道如何在资源编辑器中执行此操作(我认为 RadioButton 中有一个名为 ButtonGroup 的字段,但我不记得了)。我要做的就是通过 GUI1 的 before 方法中的代码获取五个 RadioButton 并将它们添加到 ButtonGroup 元素中。

通过 ButtonGroup,您可以使用 ButtonGroup.setSelectedIndex() 知道选择了哪个元素。当您按下按钮时,获取该值并根据具体情况采取适当的行动。

如果您有什么不明白的地方请告诉我,我会尽力帮助您。
并不是一件难事。一定有办法用资源编辑器来做到这一点,但目前我不知道如何做。

Ok I will try to explain the best I can.

When you design the first Form GUI1 the five RadioButtons must be in the same group. I don't know how to do that in the resource editor (I think there is a field called ButtonGroup in the RadioButton, but I can't remeber). What I would do is take the five RadioButton by code in the before method of GUI1 and add them to a ButtonGroup element.

With ButtonGroup you can know which element is selected using ButtonGroup.setSelectedIndex(). When you press the Button take this value and act as appropriate to the situation.

If you don't understand anything please tell me and I will try to help you.
Is not a hard thing to do. There must be a way to do it with the Resoruce editor but at the moment I don´t know how.

伊面 2024-12-30 02:17:39

正如 Shai 提到的,最好的办法是使用侦听器在单击按钮时设置按钮的“状态”,当您移动到下一个表单时,您只需检索上一个文本字段的状态。

手动代码实际上对您来说可能更快,在资源编辑器中完成大部分 UI 操作并转换为手动编写的表单。这样您就可以完全控制您的对象,并在需要时返回到 GUI 构建器表单。

As Shai mentioned, the best thing to do is to use listeners to set the "state" of the buttons on clicking them and when you move to the next form you just retrieve the state of the previous text field.

Manual code may actually be faster for you, do most of the UI in the resource editor and transfer to a form that is written manually. That way you have full control over your objects and transfer back into the GUI builder form when needed.

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