Changes

Jump to: navigation, search

Teams Winter 2011/team1/Android/Edit Contact

1,102 bytes added, 13:36, 7 April 2011
8.1 Create Edit Layout and Menu Item
== 8. Edit Contact ==
===8.1 Create Edit Layoutand Menu Item===8.1.1 Add the String value for the layout title to String.xml:===
<source lang="java">
<string name="editContact_textView">Edit Contact</string>
</LinearLayout>
</source>
8.1.6Now Add the Edit menu Item. for this purpose click on menu.xml and brouse to the xml view, and add the menu item. Here is how it looks like:<source lang="java"><?xml version="1.0" encoding="utf-8"?><menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/item1" android:title="Add Student"></item> <item android:id="@+id/item2" android:title="Delete Student"></item> <item android:id="@+id/item3" android:title="View Student"></item> <item android:id="@+id/item4" android:title="Edit Student"></item> <item android:id="@+id/item5" android:title="Send E-mail"></item></menu></source>  8.1.. Now build your project so that the ids are generated in R.java
===8.2 Create EditContactActivity===
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {// modified to implement Edit
switch (requestCode){
case CREATE_CONTACT:// Add new Contact
if (resultCode == Activity.RESULT_OK) {
studentList.addElement(new Student(intent.getExtras().getString("firstName"),
===8.5 Edit Contact In action ===
8.5.1 Build and run the project. Scrole mous buton to select a contact, and then click on the menu button of the virtual device. and then click on the EditContact menu option. Please note that the selected contact seems unselected but it's ok:<br/>
[[Image: editMenuOption.png | 450px]]<br/>
8.5.2 the Edit Contact view will apear with the selected student shown.<br/>
[[Image: editView.png | 450px]]<br/>
8.5.3 edit the Contact's info:<br/>
[[Image: editViewEdited.png | 450px]]<br/>
8.5.4 click on save contact button and see the result:<br/>
[[Image: editViewSaved.png | 450px]]<br/>
1
edit

Navigation menu