Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE Integration Manual page 49

Blackberry device applications integration guide
Table of Contents

Advertisement

_saveMenuItem = new SaveMenuItem();
setTitle(new LabelField("Tasks Demo",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
_summary = new EditField("Task Summary: ", "");
add(_summary);
// In TODO.Priority, 0 to 9 is highest to lowest priority.
String[] choices = {"High", "Normal", "Low"};
_priority = new ObjectChoiceField("Priority: ", choices, 1);
add(_priority);
String[] status = { "Not Started", "In Progress", "Completed",
"Waiting on someone else", "Deferred" };
_status = new ObjectChoiceField("Status: ", status, 0);
add(_status);
_due = new DateField("Due: ", System.currentTimeMillis() + 3600000,
DateField.DATE_TIME);
add(_due);
_note = new EditField("Extra Notes: ", "");
add(_note);
}
protected boolean onSave() {
try {
ToDoList todoList = (ToDoList)PIM.getInstance().
openPIMList(PIM.TODO_LIST, PIM.WRITE_ONLY);
ToDo task = todoList.createToDo();
task.addDate(ToDo.DUE, ToDo.ATTR_NONE, _due.getDate());
task.addString(ToDo.SUMMARY, ToDo.ATTR_NONE, _summary.getText());
task.addString(ToDo.NOTE, ToDo.ATTR_NONE, _note.getText());
task.addInt(ToDo.PRIORITY, ToDo.ATTR_NONE,
_priority.getSelectedIndex());
// ToDo.EXTENDED_FIELD_MIN_VALUE + 9 represents status.
// Add 1 to selected index so that values are correct.
// See the RIM Implementation Notes in the API docmentation for ToDo.
task.addInt(ToDo.EXTENDED_FIELD_MIN_VALUE + 9, ToDo.ATTR_NONE,
_status.getSelectedIndex() + 1);
// Save task to handheld tasks.
task.commit();
_summary.setText("");
_note.setText("");
_due.setDate(null);
_priority.setSelectedIndex(1); // Reset to "Normal" priority.
_status.setSelectedIndex(0); // Reset to "Not Started" status.
return true;
} catch (PIMException e) {
return false;
}
}
protected void makeMenu(Menu menu, int instance) {
menu.add(_saveMenuItem);
super.makeMenu(menu, instance);
}
}
}
4: Code samples
49

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment 4.6.0

Table of Contents