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


1500 / 1550 Microlink - Used - incl. warranty - shipped within 1 business day picture

1500 / 1550 Microlink - Used - incl. warranty - shipped within 1 business day

$804.00



Onset Computer Analog/Temp/RH/Light Data Logger MX1104 Onset Computer MX1104 picture

Onset Computer Analog/Temp/RH/Light Data Logger MX1104 Onset Computer MX1104

$261.31



Measurement Computing 197728B USB 1608HS-2A0 16-Channel Digital DAQ +2 Analog picture

Measurement Computing 197728B USB 1608HS-2A0 16-Channel Digital DAQ +2 Analog

$422.50



Computer Boards Measurement Computing PCM-DAS08 picture

Computer Boards Measurement Computing PCM-DAS08

$200.00



MEASUREMENT COMPUTING PCI-DDA08/16 8-channel, 16-bit Analog Output Board 48 D IO picture

MEASUREMENT COMPUTING PCI-DDA08/16 8-channel, 16-bit Analog Output Board 48 D IO

$349.99



Measurement Computing CIO-DAS08 Multifunction Analog and Digital I/O Board picture

Measurement Computing CIO-DAS08 Multifunction Analog and Digital I/O Board

$599.99







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