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

Genie 14270, Platform Support Weldment, GLL/IBM, OEM, Boom Lift
$808.54
Genie 14270, Platform Support Weldment, GLL/IBM, OEM, Boom Lift pictureOEM LEXMARK IBM Personal Wheelwriter 1000 Part: Right Hand Feed Roll Hanger Assy
$0.99
OEM LEXMARK IBM Personal Wheelwriter 1000 Part: Right Hand Feed Roll Hanger Assy pictureIBM SELECTRIC 1 TYPEWRITER PART OEM CARD GUIDE PAIR NOS
$16.99
IBM SELECTRIC 1 TYPEWRITER PART OEM CARD GUIDE PAIR NOS pictureRicoh 410508 Type H OEM Staple Ctge Savin-IBM-Toshiba-Lanier-Gestetner LOT OF 18
$90.0
Ricoh 410508 Type H OEM Staple Ctge Savin-IBM-Toshiba-Lanier-Gestetner LOT OF 18 pictureIBM OEM STAPLE CARTRIDGE Infoprint 2085/2105 5000 Staples/Box 53P6725 LOT OF 2
$22.5
IBM OEM STAPLE CARTRIDGE Infoprint 2085/2105 5000 Staples/Box 53P6725 LOT OF 2 picture






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