我已经在我需要改变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的 - 这怎么可能,一个服务保留后,活动已关闭正在运行的?正在运行、Android
下一篇:如何衡量字符串的像素宽度drawed超过Drawing.Bitmap在.NET?字符串、宽度、像素、drawed