0

I am developing a quiz application using LWUIT where users can choose from different types of quizzes.

The user has the choice of taking a timed quiz or an untimed quiz. In a timed quiz, a count down timer will be displayed on top of the screen and the test will automatically be submitted when the timer ends.

How should I implement this in LWUIT? I am looking for an approach which will tackle this problem elegantly. Would really appreciate your comments and feedback.

Thanks ,

Nikhil.

Nikhil
  • 1,279
  • 2
  • 23
  • 43

1 Answers1

2

The best way is to use an animation, just implement the Animation interface and use Form.registerAnimated(). Always return false from the animate() method and within it just update your UI based on the current time.

This is a superior approach to using the java.util.Timer API because the animation is invoked within the LWUIT EDT thread and not within a separate thread so you can just change the GUI without fear of a race condition.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • Thanks I'll look into this.. I had an intuition that LWUIT has something more to offer :) – Nikhil Feb 29 '12 at 06:02
  • 1
    Yes Shai Almog's approach is elegant ! He masters and knows LWUIT 100% ! He builts it so he masters it ! Isn't it ? – pheromix Feb 29 '12 at 06:15