@Vavid

Yep, you're absolutely right about the constructor. The relevent
Context wasn't passed as a  parameter to new HelloItemized objet.
Something is not clear to me in this tutorial: what is the Context I
should pass to the HelloItemized objet? Tutorial URL:
http://developer.android.com/resources/tutorials/views/hello-mapview.html

I tried the following (but this did nothing and my android marker has
disappeared...):

1 ) File HelloGoogleMaps.java:
-------------------------------------------------
package com.tests;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
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 com.google.android.maps.OverlayItem;

public class HelloGoogleMaps extends MapActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);

        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable =
this.getResources().getDrawable(R.drawable.androidmarker);
        HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable,this);
        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, "Hola,
Mundo!", "I'm in Mexico City!");

        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    }
    @Override
    protected boolean isRouteDisplayed()
    {
        return false;
    }
}

2 ) File : HelloItemizedOverlay.java :
----------------------------------------------------
package com.tests;

import java.util.ArrayList;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay
{
        private ArrayList<OverlayItem> mOverlays = new
ArrayList<OverlayItem>();
        private Context mContext;

        public HelloItemizedOverlay(Drawable defaultMarker, Context context)
        {
                  super(defaultMarker);
                  mContext = context;
        }

        public void addOverlay(OverlayItem overlay)
        {
            mOverlays.add(overlay);
            populate();
        }
        @Override
        protected OverlayItem createItem(int i)
        {
          return mOverlays.get(i);
        }
        @Override
        public int size()
        {
          return mOverlays.size();
        }
        @Override
        protected boolean onTap(int index)
        {
          OverlayItem item = mOverlays.get(index);
          AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
          dialog.setTitle(item.getTitle());
          dialog.setMessage(item.getSnippet());
          dialog.show();
          return true;
        }
}

Help would be appreciated...

On 26 fév, 05:52, Vadid Valiulla <[email protected]> wrote:
> Actually your problem is that the Dialog is not getting the correct
> context... Coz the constructor u initialized doesnt have the context
> passed to it... Check that and i suppose your problem should get
> solved...
>
> sorry 4 sending another message i forgot to mention the reason i gave
> the re-defined constructor...
>
> Take care...

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to