开发者

ZoomButtonsController not working

开发者 https://www.devze.com 2023-02-07 13:50 出处:网络
I added the controller\'s container to the layout. When I try to call the controller.setVisible(true) (in the touch event), I get this exception:

I added the controller's container to the layout. When I try to call the controller.setVisible(true) (in the touch event), I get this exception:

java.lang.RuntimeException: view android.widget.ZoomButtonsController$Container@44c1e490 being added, but it already has a parent

Here's the code to add the controller:

final TextView xView = (TextView)findViewById( R.id.xView);
final ZoomButtonsController controller = new ZoomButtonsController(xView );
ViewGroup zoomControlContainer = controller.getContainer();
LinearLayout layout = (LinearLayout) findViewById(R.id.parent_layout);
layout.addView(zoomControlContainer);
controller.setAutoDismissed(true);

Code to handle touch event:

   xView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            controller.setVisible(true);
            return false;
        }
    });

If I don't add the container, controller.setVisible(t开发者_StackOverflowrue) has no effect anyways. Any pointers?


Take a look at this question I think Mark Murphy does a good job of explaining what you should do and also how you should debug this if you are still having issues.


Take a look at this and this.

Why dont you use:

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

精彩评论

暂无评论...
验证码 换一张
取 消