Changes

Jump to: navigation, search

Teams Winter 2011/team1/Android/Edit Contact

866 bytes added, 12:46, 7 April 2011
8.4 Implement The EditContact in the main activity class
private Student selectedStudent;
</source>
 
8.4.2 In the onOptionsItemSelected(MenuItem item) method add the following case to the switch code block:
 
<source lang="java">
 
case R.id.item4:// Edit
// set the private field :selectedStudent so that it can be accessed later
selectedStudent = (Student)contactsList.getSelectedItem();
// create an Intent
Intent j = new Intent(this, EditContactActivity.class);
// add the selected student's data to the intent so that the EditContactActivity class can read them
j.putExtra("oldFirstName",selectedStudent.getFirstname());
j.putExtra("oldLastName", selectedStudent.getLastName());
j.putExtra("oldEmail",selectedStudent.getEmail());
// Start the EditContactActivity activity
startActivityForResult(j, EDIT_CONTACT);
break;
 
</source>
1
edit

Navigation menu