Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 41
Registered: ‎08-28-2011
My Device: 9800
My Carrier: Abc

How to make Clock for Quiz Application ?

Hi,

 

I am making a quiz application. It need a clock to count down. and I do not know how to do that. 

Can i get helping ?

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to make Clock for Quiz Application ?

Read up on Timer and TimerTask.

 

Just have a LabelField on your screen that displays the time.  To convert the time to hours and minutes look at SimpleDateFormat.

 

Then the only trick is making sure you run the LabelField update on the Event Thread using invokeLater.

 

Hopefully that will get you started....

Contributor
Posts: 41
Registered: ‎08-28-2011
My Device: 9800
My Carrier: Abc

Re: How to make Clock for Quiz Application ?

thanks Peter for your tips,

 

I did succesfully make a clock. And when I push 2nd screen , I want to this clock still display and count down with time  1st screen. How can I do that ?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to make Clock for Quiz Application ?

Not sure I understand - are you saying youwant the same label to appear on the second screen?  If so, the easiest thing to do is ot delete it from the 1st screen and add it to the second screen.  You can leave the 'timer' running. 

Contributor
Posts: 41
Registered: ‎08-28-2011
My Device: 9800
My Carrier: Abc

Re: How to make Clock for Quiz Application ?

Hi

 

I am making a quiz with time limit. In a quiz, each screen have a question and 4 answer. You use next button to go to next question. I want clock run count down and display in all question. Example in the first screen , I display clock  with time 60s and it run count down. When I checked answer and click next button to go to next question, clock is 50s. and I want in next screen ( next question), clock count down from 50s , not run from 60s .

 

Sorry for my bad English, hope you understand me.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to make Clock for Quiz Application ?

As noted, the easiest thing to do is to leave the Timer running, and move the 'countdown label from one scren to the next. 

 

I think my preivous post is the answer..