几周前我开始学习 Android,现在我需要你的帮助。我的任务是创建离线地图(使用 OSMDroid 和 Mobile Atlas Creator),上面有两个标记,它们之间的路径以及单击此标记后的一些活动。我已经完成了地图、标记和路径。这是代码(Android 2.3.3):
公共类 MainActivity 扩展 Activity {
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 的问题:如何正确地做(我的意思是如何按类划分这个程序)?非常感谢!=)