Open main menu

CDOT Wiki β

Changes

Teams Winter 2011/team1/Android/Implement Delete Option

224 bytes added, 11:19, 28 March 2011
no edit summary
=== 5. Implement Delete Option ===
5.1. In the <code>ContactList</code> class add the following lines to the <code>onOptionsItemSelected</code> method:
<presource lang="java">
case R.id.item2:
Student deleteStudent = (Student)contactsList.getSelectedItem();
}
break;
</presource>
5.2. Add the method to generate the dialog window to alert if no contact has been selected:
<presource lang="java">
public void showDialog(String message){
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.show();
}
</presource>
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.4. The list should get updated: <br/>
[[Image: A_delete2.png | 450px ]]<br/>5.5. Run the application again, but this time don't select any student and try to execute the delete option. You should get the following message:<br/>[[Image: A_view2.png | 450px ]]
1
edit