views:

356

answers:

1

My zoom controls keep zooming in when I press the button, and will not stop, am I missing something?

zoomControls = (ZoomControls) findViewById(R.id.zoom);
        zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                        mc.zoomIn();
                }
        });
        zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                        mc.zoomOut();
                }
        });
+1  A: 

Taking an educated guess that mc is a MapController, perhaps calling zoomIn() on a MapController triggers the relevant OnClickListener as well. Try logging every time you are in your onClick() to see if you get a chain of log messages. If so, then you probably can't do what you're trying to do.

CommonsWare
Ok that makes sense, but if I just want it to have the zoom controls appear and make them usable do I need to anything other map.setBuiltInZoomControls(true);map.displayZoomControls(true);?
NickTFried
No, that will suffice. And the second statement is only needed if you want to programmatically make them appear -- if your map is clickable, then users will cause the zoom controls to pop up when they tap near the bottom of the screen.
CommonsWare