문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top