BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-09-2011, 01:18 PM   #1 (permalink)
New Member
 
Join Date: Jun 2011
Model: 9800
PIN: N/A
Carrier: Rogers
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
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


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: How to add fields on screen with a loop running
Thread Thread Starter Forum Replies Last Post
Unite! Help Guide Sith_Apprentice BlackBerry Unite 17 12-25-2008 02:08 PM
BES Server 4.1 Sp1 to Sp2 upgrade problems plantagenet BES Admin Corner 5 09-05-2007 01:48 AM
Hands on review: Screen Patronus Screen Protector for the 8700c lgreenberg BBF Reviews 42 01-29-2007 08:49 PM
low level error 1209 on bes 3.6 mackynoon BES Admin Corner 0 07-19-2005 07:02 AM

Lot of 2 Vintage Genuine OEM Nukote BM160 Ribbon Apple Imagewriter NEC PC8023A
$12.75
Lot of 2 Vintage Genuine OEM Nukote BM160 Ribbon Apple Imagewriter NEC PC8023A pictureCC8: Genuine OEM Apple Mac LONG DVI to VGA Video Adapter Cable 603-2120/591-011
$10.99
CC8:  Genuine OEM Apple Mac LONG DVI to VGA Video Adapter Cable 603-2120/591-011 pictureOEM Part HARD Drive assembly 250mb SCSI Oerlikon 901-416 APPLE iTRADE-AG with c
$137.5
OEM Part HARD Drive  assembly 250mb SCSI Oerlikon 901-416 APPLE iTRADE-AG with c pictureSeagate 750GB 7200 RPM 3.5" ST3750640NS OEM Apple Hard Drive Wiped
$35.99
Seagate 750GB 7200 RPM 3.5Lot of 3 Wiped Seagate 750GB 7200 RPM 3.5" ST3750640NS OEM Apple Hard Drives
$89.99
Lot of 3 Wiped Seagate 750GB 7200 RPM 3.5






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