Search code examples
lwuitlwuit-resource-editorlwuit-form

Accessing forms created through LWUIT resource editor using code


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.


Solution

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