Page 310

Chapter 11:

Application: Find a Friend

mCursor.deleteRow(); mCursor.deactivate(); mCursor = null; } } }

In the next section, you will create the Activity that will draw your Google Maps Overlay. The FriendsMap activity will read the full recordset of friends from the Friends database and write each to the Overlay.

Creating the FriendsMap Activity

The FriendsMap Activity is the final Activity that will be callable from the main application. This Activity will call your recordset from the Friends database and draw a circle on a Google Map for each friend. The Activity will also draw a circle for you at your current location. You need to begin by adding two new files to your project, friendsmap.xml and FriendsMap.java. Because you have seen the layout for the friendsmap.xml file in Chapter 9, there is no need to fully explain it here. You are using a RelativeLayout to place four Buttons over a Google Map. The full friendsmap.xml file should look like this:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <view class="com.google.android.maps.MapView" android:id="@+id/myMap" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/buttonZoomIn" style="?android:attr/buttonStyleSmall" android:text="+" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/buttonMapView" style="?android:attr/buttonStyleSmall" android:text="Map" android:layout_alignRight="@+id/myMap" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:id="@+id/buttonSatView" style="?android:attr/buttonStyleSmall" android:text="Sat" android:layout_alignRight="@+id/myMap"

293

McGraw.Hill.Android.A.Programmers.Guide.Jul.2008  

Android ™ A Programmer’s Guide This page intentionally left blank A Programmer’s Guide J.F. DiMarzio New York Chicago San Francisco Lisbon L...

McGraw.Hill.Android.A.Programmers.Guide.Jul.2008  

Android ™ A Programmer’s Guide This page intentionally left blank A Programmer’s Guide J.F. DiMarzio New York Chicago San Francisco Lisbon L...

Advertisement