Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6820555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:26:19+00:00 2026-05-26T21:26:19+00:00

I followed Google’s Map View tutorial from this link http://developer.android.com/resources/tutorials/views/hello-mapview.html I’ve done the first

  • 0

I followed Google’s Map View tutorial from this link http://developer.android.com/resources/tutorials/views/hello-mapview.html
I’ve done the first about Creating Map activity, but have problems with Adding Overlays. Here is the source code:

package rs.iz.stevy.wifi;

import java.util.ArrayList;

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

public class Overlay extends ItemizedOverlay {

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

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

    public Overlay(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
    }
    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;
    }

}

Error appear at this line:
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
Eclipse shows mContext cannot be resolved to variable.

Here is the Activity class:

rs.iz.stevy.wifi;

import java.util.List;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

import android.graphics.drawable.Drawable;
import android.os.Bundle;


public class WiFiKupacicaActivity extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MapView mapa= (MapView) findViewById(R.id.Mapa1);
        mapa.setBuiltInZoomControls(true);
        mapa.setSatellite(true);

       GeoPoint initGeoPoint = mapa.getMapCenter();

    List<Overlay> mapOverlays = mapa.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.kupacica);
    Overlay itemizedoverlay = new Overlay (drawable);

    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }

Eclipse show error Cannot instantiate Overlay at this line:
Overlay itemizedoverlay = new Overlay (drawable);

If you see here any error that can be easily fixed please answer cause this are my first attempts to write an android app.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:26:20+00:00Added an answer on May 26, 2026 at 9:26 pm

    The first error is because you defined mContext as a local variable in the constructor instead of as an instance variable. To remedy, move the Context mContext; line out of the constructor (put it right before this line public Overlay(Drawable defaultMarker, Context context) {). You want to declare instance variables outside of any method, but inside the class itself.

    Your second error occurs because Overlay is an Abstract class. You cannot instantiate an abstract class with “new”. What you want to do here is instantiate your Overlay subclass. In your import statements, you’re importing com.google.android.maps.Overlay so it thinks you’re instantiating that rather than your subclass. To fix, replace

    Overlay itemizedoverlay = new Overlay (drawable);
    

    with

    rs.iz.stevy.wifi.Overlay itemizedoverlay = new rs.iz.stevy.wifi.Overlay (drawable);
    

    In practice, you should avoid giving a class the name of an abstract class already in its own hierarchy (to avoid import errors like this).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed the instructions in the Android WebView tutorial (at http://developer.android.com/resources/tutorials/views/hello-webview.html ). When I
i am trying to run google map tutorial using following link http://mobiforge.com/developing/story/using-google-maps-android followed all
I recently followed this tutorial on Google Cloud SQL and GWT: http://code.google.com/apis/sql/docs/developers_guide_java.html I deployed
I am trying to implement this example http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html and i have followed exactly all
I followed all of the instructions so far from: http://code.google.com/p/appengine-jruby/wiki/RunningRails and http://gist.github.com/268192 Currently, I'm
I am new to development. I followed step by step instructions from http://code.google.com/apis/maps/articles/flashmapinwpf.html to
I've followed instructions http://code.google.com/webtoolkit/doc/latest/tutorial/gettingstarted.html in order to create sample GWT program. Now I would
I Followed this tutorial for my Restlet server in the Google App Engine: http://wiki.restlet.org/docs_2.0/13-restlet/21-restlet/318-restlet/303-restlet.html
I've downloaded the JSON framework DMG from http://code.google.com/p/json-framework/downloads/list . I followed Option 3 here:
I have followed the Hello World example from Google's Android developer's guide. When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.