0

我正在使用带有叠加层的mapview,在这里我选择叠加层项目它显示特定叠加层项目的信息......现在我想在点击窗口一侧时关闭信息框..这里是我的示例代码..

popUp = getLayoutInflater().inflate(R.layout.village_popupwindow, null,
                false);
final GeoPoint selectedPoint = item.getPoint();     
mapParams = new MapView.LayoutParams(500, 300, selectedPoint,130, -200, MapView.LayoutParams.CENTER);
                mapView.addView(popUp, mapParams);

        ImageView imageView = (ImageView) findViewById(R.id.homeImage);
        TextView textTitle = (TextView) popUp.findViewById(R.id.text_title);
        TextView adress = (TextView) popUp.findViewById(R.id.text_plan);
        textTitle.setText(arrayListForAmenitiesDto.get(storeId).getName());
        adress.setText("Read more...");

任何人都知道如何关闭此弹出式布局?...不使用弹出式布局中的关闭按钮...我只想关闭弹出式布局,同时单击 popuplayout 之外。

4

3 回答 3

0

只需使用此代码在外部触摸时关闭弹出窗口

    popUp.setOnTouchListener(new OnTouchListener() {            

        public boolean onTouch(View arg0, MotionEvent motionEvent) {

            return true;
        }
    });
于 2013-05-16T13:48:47.563 回答
0

嗨,我解决了上述问题,我的回答是

otherHomesPlace.setOnFocusChangeListener(new OnFocusChangeListener() {

                @Override
                public void onFocusChanged(ItemizedOverlay overlay,
                        OverlayItem newFocus) {
                    // TODO Auto-generated method stub
                    System.out.println("Focus changed"+otherHomesPlace.getFocus());
                    if(otherHomesPlace.getFocus()==null){
                    popUp.setVisibility(View.GONE);
                }else{
                    popUp.setVisibility(View.VISIBLE);
                }
                }
            });
于 2013-02-21T13:17:07.787 回答
0

您可以通过将onTouchListener注册到 mapView来删除该弹出窗口。例如

mapView.setOnTouchListener(new OnTouchListener() {          
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        try{
            //you can remove your popup here. hope this helps.
        }catch (Exception e) {}
      return false;
    }
});
于 2013-02-21T10:30:48.057 回答