// Start/end time selection
final VerticalFieldManager vfm = new VerticalFieldManager();
_choiceField =
new ObjectChoiceField("When:", new Object[] { "Depart Now",
"Depart At", "Arrive At" }, 0);
_choiceField.setChangeListener(new FieldChangeListener() {
/**
* @see net.rim.device.api.ui.FieldChangeListener#fieldChanged(Field,
* int)
*/
public void fieldChanged(final Field field, final int context) {
if (context == ChoiceField.CONTEXT_CHANGE_OPTION) {
final int idx = _choiceField.getSelectedIndex();
if (idx == DEPART_NOW) {
_dateField.setEnabled(false);
} else {
_dateField.setEnabled(true);
_dateField.setFocus();
}
}
}
});
vfm.add(_choiceField);
final DateFormat dateFormat =
DateFormat.getInstance(DateFormat.DATETIME_DEFAULT);
_dateField = new DateField("", System.currentTimeMillis(), dateFormat);
_dateField.setEnabled(false);
vfm.add(_dateField);
add(vfm);
// Initialize a button for intitiating a travel time query
final HorizontalFieldManager hfm =
new HorizontalFieldManager(Field.FIELD_HCENTER);
final ButtonField travelButton =
new ButtonField("Get Travel Time", ButtonField.CONSUME_CLICK
| ButtonField.NEVER_DIRTY);
hfm.add(travelButton);
add(hfm);
travelButton.setChangeListener(new FieldChangeListener() {
public void fieldChanged(final Field field, final int context) {
findTravelTime();
}
});