Changes

Jump to: navigation, search

Teams Winter 2011/team1/BlackBerry/Add Mapping Option

1,797 bytes added, 13:27, 7 April 2011
no edit summary
=== 10. Add Mapping Option ===
10.1. In order to implement Address Locator we need to add address field and getter/setter methods to <code>Student</code> class: <source lang="java"> public Student(String firstName, String lastName, String email, String address) { this.firstName = firstName; this.lastName = lastName; this.email = email; this.email = address; //add address field }  public String getAddress(){ return address; } public void setAddress(String address){ this.address = address; } </source>10.2. Add EditTextFields to Add, Edit and view option:viewItem <source lang="java"> BasicEditField addressField = new BasicEditField("address: ",student.getAddress(),50,Field.NON_FOCUSABLE); addressField.setBorder(roundedBorder); addressField.setBackground(solidBackground); add(addressField); </source>addItem <source lang="java> EditField inputField4 = new EditField("Student's address: ",""); addDialog.add(inputField4);  // Display the dialog and add a new element to the list if(addDialog.doModal() == 0) { addElementToList(new Student(inputField1.getText(),inputField2.getText(),inputField3.getText(), inputField4.getText())); } </source>editItem <source lang="java"> EditField inputField4 = new EditField("Address: ",studentOld.getAddress()); editDialog.add(inputField4);  if(editDialog.doModal() == 0) { studentNew.setFirstName(inputField1.getText()); studentNew.setLastName(inputField2.getText()); studentNew.setEmail(inputField3.getText()); studentNew.setAddress(inputField4.getText()); //set Address editListElement(studentOld, studentNew); } </source>10.3. Add the Map Option to the manu:<br/>
<source lang="java">
//Show the address on the map
_mainScreen.addMenuItem(mapItem);
</source>
10.24. Implement address locator:
<source lang="java">
mapItem.setCommand(new Command(new CommandHandler(){
1
edit

Navigation menu