BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-09-2010, 04:36 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to load the second list in spinbox if I select/focus an item of the first list?

Please Login to Remove!

How to load the second list in spinbox if I select/focus an item of the first list?

public class SpinTest extends BaseScreen implements FocusChangeListener {

final String[] stateList={"New York","Washington"};
final String[] NYcities={"Manhattan","Queens","Brooklyn","Bronx"} ;
final String[] WashCities={"Seattle","Redmond","Kent","Bellevue"} ;

public SpinTest(){
SpinBoxFieldManager spinBoxMgr = new SpinBoxFieldManager();

SpinBoxField spinBoxStates = new TextSpinBoxField(stateList);
spinBoxStates.setFocusListener(this);

SpinBoxField spinBoxCities= new TextSpinBoxField(NYcities);

spinBoxMgr.add(spinBoxStates );
spinBoxMgr.add(spinBoxCities);

add(spinBoxMgr);
}

public void focusChanged(Field field, int context) {
if (spinBoxStates== field) {
String sel = (String) spinBoxStates.get(spinBoxStates.getSelectedIndex() );
if (sel.equals("New York")) {

//I have to load all the cities of New York in second wheel if I select "New York" in first wheel
}
else if(sel.equals("Washington")) {
//I have to load all the cities of Washington in second wheel if I select "Washington" in first wheel
}

}
Offline  
Old 08-10-2010, 08:42 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Somebody pls help me.
Offline  
Old 08-10-2010, 02:29 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

When I try with following code, it throws "IllegalArgumentException".
Please somebody help me. It's urgent.

Code:
public void focusChanged(Field field, int context) {
if (spinBoxStates== field) {
String sel = (String) spinBoxStates.get(spinBoxStates.getSelectedIndex() );
if (sel.equals("New York")) {

//I have to load all the cities of New York in second wheel if I select "New York" in first wheel

TextSpinBoxField desc = new TextSpinBoxField(NYcities);
spinBoxMgr.replace(spinBoxCities,desc);
//spinBoxCities =  new TextSpinBoxField(NYcities);
//How to refresh the manager

}
else if(sel.equals("Washington")) {

//I have to load all the cities of Washington in second wheel if I select "Washington" in first wheel

}

}
Offline  
Old 08-12-2010, 12:02 PM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solved !!!

Code:
public void focusChanged(Field field, int context) {
if (spinBoxStates== field) {
String sel = (String) spinBoxStates.get(spinBoxStates.getSelectedIndex() );
if (sel.equals("New York")) {
spinBoxCities.setChoices(NYcities);
}
else if(sel.equals("Washington")) {
spinBoxCities.setChoices(WashCities);
}

}

Last edited by romah : 08-12-2010 at 12:04 PM.
Offline  




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