I've been following this tutorial: http://developer.android.com/resources/tutorials/views/hello-mapview.html
but in onTap
mContext is throwing a NullPointerException.. anyone know why? Here's my code..
public class Mapitems extends ItemizedOverlay{
Context mContext;
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
public Mapitems(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
}
public Mapitems(Drawable defaultMarker, Context context) {
super(defaultMarker);
mContext = context;
}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}
@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;
}
@Override
public int size() {
return mOverlays.size();
}
}
//edit: I'm still having problems with this. Bounty is for anyone who can give me an explanation as to why I'm getting this sort of error and how would I correct it?
//edit2: It seems past answer allows me to click the item but doesnt show its icon in the mapview.. anyone know why??