我已经开始研究Android的几个星期前,现在我需要你的帮助。 我的任务是创建离线地图(使用OSMDroid和移动阿特拉斯造物主),上面有两个标志,点击这个标记后,他们与活动之间的路径。 我所做的地图上,标记和路径。 下面是代码(安卓2.3.3):
公共类MainActivity延伸活动{
private MapView mapView;
LocationManager locationManager;
ArrayList<OverlayItem> overlayItemArray;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = new MapView(this, 256);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
mapView.getController().setZoom(15);
mapView.getController().setCenter(new GeoPoint(54.332, 48.389));
mapView.setUseDataConnection(false);
overlayItemArray = new ArrayList<OverlayItem>();
OverlayItem olItem = new OverlayItem("Here", "SampleDescription", new GeoPoint(54.332, 48.389));
overlayItemArray.add(olItem);
overlayItemArray.add(new OverlayItem("Hi", "You're here", new GeoPoint(54.327, 48.389)));
PathOverlay myPath = new PathOverlay(Color.RED, this);
myPath.addPoint(new GeoPoint(54.327, 48.389));
myPath.addPoint(new GeoPoint(54.332, 48.389));
mapView.getOverlays().add(myPath);
DefaultResourceProxyImpl defaultResourceProxyImpl = new DefaultResourceProxyImpl(this);
ItemizedIconOverlay<OverlayItem> myItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(overlayItemArray, null, defaultResourceProxyImpl);
mapView.getOverlays().add(myItemizedIconOverlay);
setContentView(mapView); //displaying the MapView
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}问题:如何实现此标记的onClick法? 而对于profy另一个问题:如何做是正确的(我的意思是如何除以类此程序)? 非常感谢! =)