views:

229

answers:

1

Hi,

I'm trying to complete the Android MapView tutorial @ www.developer.android.com/resources/tutorials/views/hello-mapview.html

I think I've done the entire thing correctly but I'm getting an error message in Eclipse. I'm sure why. The problematic line of code is

private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();

I'm relatively new to Java but I've gone through the forums of different things and I really have no idea on this one. I've [attached][2] a screen shot of the development environment - hopefully it wont be anything too obvious or hard to fix either!

http://www.limedomains.com/files/download/34780?dirname=&amp;file_name=hellogooglemaps.jpg

Cheers

Tom :)

** As requested heres the source code and the screenshot link is updated to something that works**

package com.example.hellogooglemaps;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();

public class HelloItemizedOverlay extends ItemizedOverlay{

    public HelloItemizedOverlay(Drawable defaultMarker) {
          super(boundCenterBottom(defaultMarker));
        }

    @Override
    protected OverlayItem createItem(int i) {
      return mOverlays.get(i);
    }

    public void addOverlay(OverlayItem overlay) {
        mOverlays.add(overlay);
        populate();
    }

    @Override
    public int size() {
      return mOverlays.size();
    }

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

    @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;
    }
}
A: 

Your screenshot is impossible to read.. please copy/paste what the logcat says...

For my personnal use, i use this code: List mapOverlays;

Profete162
updated with requests...
Tom