Changes

Jump to: navigation, search

Teams Winter 2011/team1/Android/Implement Delete Option

495 bytes added, 12:02, 28 March 2011
no edit summary
5.1. In the <code>ContactList</code> class add the following lines to the <code>onOptionsItemSelected</code> method:
<pre>
case R.id.item2: studentList.removeElement(Student deleteStudent = (Student)contactsList.getSelectedItem(); if (deleteStudent != null){ studentList.removeElement(deleteStudent); displayData(studentList); } else { showDialog("No contact was selected!"); }
break;
</pre>
5.2. Add the method to generate the dialog window to alert if no contact has been selected: <pre> public void showDialog(String message){ AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setMessage(message); alertDialog.show(); } </pre>5.3. Run the application, select one student from the list, press menu and select "Delete Student":<br/>
[[Image: A_delete1.png | 450px]]<br/>
5.34. The list should get updated: <br/>
[[Image: A_delete2.png | 450px ]]
1
edit

Navigation menu