06-28-2010 07:37 PM
Thread [Ritis_Maps(180)id=253124608] (Suspended (exception IllegalStateException))
LocationPicker(Screen).setManager(Manager, int) line: 6219
VerticalFieldManager(Manager).insertInternal(Field , int) line: 2203
VerticalFieldManager(Manager).add(Field) line: 545
TitleStatusManager.add(Field) line: 609
AdvancedIncidentListOptions(Screen).add(Field) line: 288
AdvancedIncidentListOptions.addComponents() line: 147
AdvancedIncidentListOptions.<init>() line: 93
I have a MainScreen in which I am adding my LocationPicker. I call add(locationPicker);
I call this method before, to set up the locationPicker.
private void readyLocationPicker(){
Vector locationpick = new Vector();
locationpick.addElement(GPSLocationPicker.getInsta nce());
Landmark[] landmarks = new Landmark[1];
landmarks[0] = new Landmark("DC Beltway", "Center of 495 Beltway", new QualifiedCoordinates(LATITUDE_CENTER_OF_DC_BELTWAY , LONGITUDE_CENTER_OF_DC_BELTWAY, Float.NaN, Float.NaN, Float.NaN), null);
final SuggestedLocationPicker slp = SuggestedLocationPicker.getInstance("Suggested Locations...", landmarks);
locationpick.addElement(slp);
locationpick.addElement(EnterLocationPicker.getIns tance(true));
locationpick.addElement(MapsLocationPicker.getInst ance());
locationpick.addElement(RecentLocationPicker.getIn stance());
locationpick.addElement(ContactsLocationPicker.get Instance(true));
LocationPicker.Picker[] locationPickersArray = new LocationPicker.Picker[locationpick.size()];
locationpick.copyInto(locationPickersArray);
locationPicker = LocationPicker.getInstance(locationPickersArray);
locationPickListener = new LocationPicker.Listener() {
public void locationPicked(Picker picker, Landmark location) {
if(picker==slp){
//TODO: Change radius field to 30 Miles
choiceRadius.setSelectedValue(30);
}
System.out.println("Landmark: " + location);
}
};
locationPicker.setListener(locationPickListener);
}
I have no idea what is going on, and why it won't work.
Thanks.
Solved! Go to Solution.
06-29-2010 01:52 PM
I can't figure this out, does anyone have a clue as to what may be causing this?
06-30-2010 01:21 PM
From where are you calling readyLocationPicker?
07-01-2010 01:39 PM - edited 07-01-2010 01:43 PM
public AdvancedIncidentListOptions()
{
readyComponents();
addComponents();
}
The constructor for a subclass of MainScreen,
private void readyComponents(){
readyLocationPicker();
choiceRadius = new NumericChoiceField("Radius(mi):", 5, 50, 5, 2);
timeNumber = new NumericChoiceField("", 1, 20, 1, 0){
public void layout(int width, int height){
super.layout(width,height);
setExtent((getWidth()/5),20);
}
};
.....
}
Then adding it screwed everything up:
private void addComponents(){
LabelField lblLocation = new LabelField("Location:");
lblLocation.setFont(Font.getDefault().derive(Font. BOLD, Font.getDefault().getHeight() + 2));
add(new LabelField("Location:"));
//PROBLEM: add(locationPicker);
add(choiceRadius);
07-02-2010 03:41 PM
Where else could I put this so that it works, (if that is the problem)? Is this a general error that someone understands?
07-02-2010 04:23 PM
Oh, it extends Screen. Silly me. Here's how I got it to work:
locationPickerButton = new ButtonField("Location", ButtonField.CONSUME_CLICK | ButtonField.FIELD_RIGHT);
locationPickerButton.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
locationPicker.show();
locationPickerButton.setLabel(locationPickerLocati on.getName());
}
});