map views

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

map views

Postby dewitrydan » Wed Feb 16, 2011 11:07 am

I was wondering, why do I get null pointer exception from the following bit of code:
Code: Select all
protected void onCreate(Bundle icicle) {
      // TODO Auto-generated method stub
      super.onCreate(icicle);
      mapView = (MapView) findViewById(R.id.mapview);
      mapView.setBuiltInZoomControls(true);
      setContentView(R.layout.main);

   }


and why the next bit of code runs without any problems:
Code: Select all
   @Override
   protected void onCreate(Bundle icicle) {
      // TODO Auto-generated method stub
      super.onCreate(icicle);
      setContentView(R.layout.main);
      mapView = (MapView) findViewById(R.id.mapview);
      mapView.setBuiltInZoomControls(true);

   }


thanks for your help
This will improve my understanding
dewitrydan
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Sep 06, 2010 12:03 pm

Top

Re: map views

Postby JoxTraex » Sat Feb 19, 2011 12:48 am

Did you put the mapview inside your main.xml file??

///
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="Your Maps API Key"
/>
////
JoxTraex
Developer
Developer
 
Posts: 25
Joined: Wed Jan 26, 2011 12:29 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests