14.01.2013 Views

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7: Maps, Geocoding, and Location-Based Services<br />

242<br />

To remove a View from a MapView, call removeView, passing in the View instance you wish to remove,<br />

as shown below:<br />

mapView.removeView(editText2);<br />

Mapping Earthquakes Example<br />

The following step-by-step guide demonstrates how to build a map-based Activity for the Earthquake<br />

project you started in Chapter 5. The new MapActivity will display a map of recent earthquakes using<br />

techniques you learned within this chapter.<br />

1. Create a new earthquake_map.xml layout resource that includes a MapView, being sure to<br />

include an android:id attribute and a android:apiKey attribute that contains your Android<br />

Maps API key.<br />

<br />

<br />

<br />

<br />

2. Create a new EarthquakeMap Activity that inherits from MapActivity. Use setContentView<br />

within onCreate to infl ate the earthquake_map resource you created in Step 1.<br />

package com.paad.earthquake;<br />

import android.os.Bundle;<br />

import com.google.android.maps.MapActivity;<br />

public class EarthquakeMap extends MapActivity {<br />

}<br />

@Override<br />

public void onCreate(Bundle icicle) {<br />

super.onCreate(icicle);<br />

setContentView(R.layout.earthquake_map);<br />

}<br />

@Override<br />

protected boolean isRouteDisplayed() {<br />

return false;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!