diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 048a548..f6dd90d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -16,18 +16,12 @@
android:label="@string/title_activity_main" >
-
-
-
-
-
-
diff --git a/res/layout/activity_friend_adder.xml b/res/layout/activity_friend_adder.xml
index f1b3aa5..86747eb 100644
--- a/res/layout/activity_friend_adder.xml
+++ b/res/layout/activity_friend_adder.xml
@@ -11,7 +11,7 @@
android:layout_height="wrap_content"
android:text="@string/friend_name"/>
- adapter =
new ArrayAdapter(this, android.R.layout.simple_list_item_1, friends);
ListView list = (ListView) findViewById(R.id.friendList);
@@ -74,7 +76,7 @@ public class MainActivity extends Activity {
}
}
else if(v.getId() == R.id.add_button){
-
+
}
else{
System.out.println(" Unknown View!!!");
@@ -99,21 +101,52 @@ public class MainActivity extends Activity {
System.out.println("Unexpected behaviour ! What do ? ?"); //FIXME : Log instead, or message pop up
}
-// Button myButton = (Button)findViewById(R.id.add_button);
-// String myStr = "";
-// for (int i = 0; i < friends.length; i++) {
-// myStr += friends[i];
-//
-// }
-// myButton.setText(myStr);
+ // Button myButton = (Button)findViewById(R.id.add_button);
+ // String myStr = "";
+ // for (int i = 0; i < friends.length; i++) {
+ // myStr += friends[i];
+ //
+ // }
+ // myButton.setText(myStr);
ListView list = (ListView) findViewById(R.id.friendList);
- ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, friends);
+ ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, friends);
list.setAdapter(adapter); // updates list of friends
-
+
return true;
}
+ protected void onActivityResult(int requestCode, int resultCode, Intent pData)
+ {
+ if (resultCode == Activity.RESULT_OK )
+ {
+ String new_friend = pData.getExtras().getString( FriendAdder.RES_FRIEND );
+
+ Log.v( TAG, "Retrieved Value zData is "+ new_friend );
+
+// Button myButton = (Button)findViewById(R.id.add_button);
+// myButton.setText(new_friend);
+
+ ListView list = (ListView) findViewById(R.id.friendList);
+ friends = addItem(new_friend);
+ ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, friends);
+ list.setAdapter(adapter); // updates list of friends
+
+ }
+ else{
+ Log.v( TAG, "Problem : Unexpected requestCode");
+ }
+ }
+
+ private String[] addItem(String new_friend) {
+ ArrayList temp = new ArrayList();
+ temp.add(new_friend); // Adds new friend in first position
+ for (int i = 0; i < friends.length; i++) {
+ temp.add(friends[i]);
+ }
+ return temp.toArray(new String[temp.size()]);
+ }
+
private String[] removeItem(String friend) {
//FIXME : Checks here
ArrayList temp = new ArrayList();