You need to place the following line before findViewById()...
setContentView(R.layout.main);
--
Jack Ha
Open Source Development Center
・T・ ・ ・Mobile・ stick together
The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.
On Jul 24, 7:31 am, saptarshi chatterjee
<[email protected]> wrote:
> Friends,
>
> in the following application----------
>
> package mycom.ju.gmap;
>
> //import HelloItemizedOverlay;
>
> import mycom.ju.gmap.R;
> import android.graphics.drawable.Drawable;
> import android.os.Bundle;
> import android.view.View;
> import android.webkit.WebSettings;
> import android.webkit.WebView;
> import android.widget.*;
>
> import com.google.android.maps.GeoPoint;
> import com.google.android.maps.MapActivity;
> import com.google.android.maps.MapView;
> import com.google.android.maps.Overlay;
>
> import java.util.ArrayList;
> import java.util.List;
>
> import com.google.android.maps.ItemizedOverlay;
> import com.google.android.maps.OverlayItem;
>
> public class gmap extends MapActivity {
> //Called when the activity is first created.
>
> MapView mapView;
> Toast toast;
>
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
>
> try{
> mapView = (MapView)findViewById(R.id.mapv);
> mapView.setBuiltInZoomControls(true);
> mapView.displayZoomControls(true);
> mapView.setTraffic(true);
> }
> catch(Exception e){ toast = Toast.makeText(this,e.toString(),
> Toast.LENGTH_LONG);
> toast.show();
> }
>
> setContentView(R.layout.main);
>
> }
>
> @Override
> protected boolean isRouteDisplayed() {
> return true;
> }
>
> }
>
> -------main.xml-----------------------
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
> android:id="@+id/mainlayout"
> android:orientation="vertical"
> android:layout_width="fill_parent"
> android:layout_height="fill_parent" >
>
> <com.google.android.maps.MapView
> android:id="@+id/mapv"
> android:layout_width="fill_parent"
> android:layout_height="fill_parent"
> android:clickable="true"
> android:apiKey="02OwWVKUsUMSUwUZPEOHkWSQge2bW6FOISMYvDw"
> />
>
> </LinearLayout>
>
> The map is showing perfectly but but not in traffic view , neither the
> zooming button is visible . I used the try -- catch just to check
> where the problem is . When ever I'm using mapv object to call any
> method of MapView class it's giving Null Pointer Exception . I even
> tried other constructor of MapView class like
>
> MapView( this, "02OwWVKUsUMSUwUZPEOHkWSQge2bW6FOISMYvDw") ;
>
> I even checked whether mapv contains null or not [ using mapv.equals
> (null)] . But it's not null either.
>
> But problem remains the same . Please helppppp .
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---