我的应用程序中有一个设置的位置代码。我想在单击位置图标时获取地址信息。如何使用点击事件
public class MyActivity extends MapActivity implements LocationListener
{
MapView mapView;
MapController mc;
private MyLocationOverlay myLocOverlay;
private String provider;
private LocationManager lm;
Drawable location = null;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
mapView = (MapView) findViewById(R.id.mview);
mc = mapView.getController();
mapView.setBuiltInZoomControls(true);
mc.setZoom(15);
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
provider = lm.getBestProvider(criteria, false);
Location location = lm.getLastKnownLocation(provider);
if(location != null){
onLocationChanged(location);
}
}
@Override
protected void onResume(){
super.onResume();
lm.requestLocationUpdates(provider, 400, 1, this);
myLocOverlay = new MyLocationOverlay(location.this, mapView);
myLocOverlay.enableMyLocation();
mapView.getOverlays().add(myLocOverlay);
myLocOverlay.runOnFirstFix(new Runnable() {
@Override
public void run() {
mc.animateTo(myLocOverlay.getMyLocation());
}
});
mapView.postInvalidate();
}
@Override
protected void onPause() {
super.onPause();
lm.removeUpdates(this);
myLocOverlay.disableMyLocation();
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
@Override
public void onLocationChanged(Location location) {
double lat = location.getLatitude();
double lng = location.getLongitude();
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}