OnTouchListener没有响应我有以下代码显示在谷歌地图中的实际位置:安卓:在MapView的
public class LocationProjectActivity extends MapActivity implements OnTouchListener {
private MapController mapController;
private MapView mapView;
private LocationManager locationManager;
private MyOverlays itemizedoverlay;
private MyLocationOverlay myLocationOverlay;
private GeoPoint MyPoint;
public static int longitude;
public static int latitude;
private GeoPoint destinationPoint;
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
mapView.computeScroll();
mapController = mapView.getController();
mapController.setZoom(13);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, new GeoUpdateHandler());
myLocationOverlay = new MyLocationOverlay(this, mapView);
mapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {
mapView.getController().animateTo(myLocationOverlay.getMyLocation());
}
});
}
@Override
public boolean onTouch(View v, MotionEvent event) {
System.out.println("SCREEN WAS CLICKED");
return true;
}
我想要做的就是抓时,我触摸屏幕,但方法不会被调用。我已经搜查,发现这一点: OnTouch in map
我都试过了,并且作品是唯一的代码如下:
mapView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// Your code and remember to return true!
return (true);
}
});
的问题是,如果我使用此代码,我的MapView失去自然一扔和缩放它已经拥有了,那么我怎么能在我的MapView中拥有一切?
谢谢。
你为什么要touchListner什么样的操作,你会在这里执行?请告诉我 。感谢:) – SALMAN 2012-07-21 19:28:52
我想添加一个图标或东西来指示用户触摸屏幕 – 2012-07-21 20:38:24