如何更改标志上自来水覆盖为Android? [英] How to change the marker for the overlay on tap for android?

查看:159
本文介绍了如何更改标志上自来水覆盖为Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我需要改变overlayitem的绘制,当用户点击它的应用程序。我使用下面的code来实现这种效果:

i have made an application in which i need to change the drawable of an overlayitem when a user clicks on it. i am using the following code to achieve this effect:

        protected boolean onTap(int index) {
        OverlayItem item = mOverlays.get(index);
        if(item.getTitle().equals("true")){
            if(item.getMarker(OverlayItem.ITEM_STATE_FOCUSED_MASK).equals(greenMarker)){
                item.setMarker(orangeMarker);
                view1ComplainPoleList.add(item.getSnippet());
                Log.i("adding",item.getSnippet());
                map.invalidate();
            }
            else{
                item.setMarker(greenMarker);
                view1ComplainPoleList.remove(item.getSnippet());
                Log.i("removing",item.getSnippet());
                map.invalidate();
            }
        }
        return true;
    }

但是,这似乎并不奏效。每当我点击它从视野中消失了overlayitem。什么错误?

But this does not seem to be working. whenever i click on an overlayitem it disappears from view. what is going wrong?

更新:

您也可以告诉我如何加载新的看法时,地图滚动...?

could you also tell me how to load new views when the map is scrolled...?

感谢你在前进。

推荐答案

这是很简单,做

This is very simple to do:

protected boolean onTap(int index) {
    OverlayItem item = mOverlays.get(index);
    //Get the new Drawable
    Drawable marker = mContext.getResources().getDrawable(R.drawable.icon);
    //Set its bounds
    marker.setBounds(0,0,marker.getIntrinsicWidth(),marker.getIntrinsicHeight());
    //Set the new marker
    item.setMarker(marker);
    //Return true! Do not invalidate
    return true;
}

这篇关于如何更改标志上自来水覆盖为Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆