BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 06-09-2011, 01:18 PM   #1
zpluo
New Member
 
Join Date: Jun 2011
Model: 9800
PIN: N/A
Carrier: Rogers
Posts: 1
Question How to add fields on screen with a loop running

Please Login to Remove!

Hi there,

I'm new to BB development and trying to have some buttons on the screen and a loop as a countdown timer running togather. But my codes only add the buttons on the screen after the loop finishes. Which kinds of Screen and Timer Classes should I use. My codes are as below and in the attachment. Thanks.

public class gameScreen extends MainScreen {
boolean answered;
long startTime;
RadioButtonGroup rbGroup;
String[] set;
RadioButtonField[] radioButton;
ButtonField submitButton;
FieldChangeListener submitFCL;
public gameScreen() {
answered = false;
startTime = System.currentTimeMillis();
rbGroup = new RadioButtonGroup();
radioButton = new RadioButtonField[4];
for (int i = 0; i < 4; i++) {
radioButton[i] = new RadioButtonField(set[i], rbGroup, false);
add(radioButton[i]);
}
submitButton = new ButtonField("Submit");
add(submitButton);
submitFCL = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
int valueOfRadioButton = rbGroup.getSelectedIndex();
if(set[valueOfRadioButton].equals("A"))
Dialog.alert("Answer is right!");
else Dialog.alert("Answer is wrong!");
answered = true;
}
};
submitButton.setChangeListener(submitFCL);
long leftTime = 3000-(System.currentTimeMillis() - startTime);
while ((leftTime >= 0) && !answered) {
leftTime = 3000-(System.currentTimeMillis() - startTime);
}
if (leftTime <= 0);
Dialog.inform("Time Out!");
}}
Attached Files
File Type: txt game.txt (1.2 KB, 2 views)

Last edited by zpluo; 06-09-2011 at 02:22 PM.. Reason: add attachment
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads for: How to add fields on screen with a loop running
Thread Thread Starter Forum Replies Last Post
BES Server 4.1 Sp1 to Sp2 upgrade problems plantagenet BES Admin Corner 5 09-05-2007 01:48 AM
low level error 1209 on bes 3.6 mackynoon BES Admin Corner 0 07-19-2005 07:02 AM


Vintage Printing Letterpress Block Man Balancing Many Packages On Back picture

Vintage Printing Letterpress Block Man Balancing Many Packages On Back

$9.99



Vintage Tri Cone Drill Bit Oil Gas Steampunk 6LB CALIFORNIA Mining Relic picture

Vintage Tri Cone Drill Bit Oil Gas Steampunk 6LB CALIFORNIA Mining Relic

$95.00



Vintage Set 81-R ICC Inspection Gage Blocks Incomplete picture

Vintage Set 81-R ICC Inspection Gage Blocks Incomplete

$79.99



Lot of 3 Vintage micrometers picture

Lot of 3 Vintage micrometers

$35.00



Vintage Goldblatt Drywall Tool picture

Vintage Goldblatt Drywall Tool

$17.50



2 Vintage French Military Circuit Boards For Scrap Gold Recovery And Other PM picture

2 Vintage French Military Circuit Boards For Scrap Gold Recovery And Other PM

$22.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.