I simply want a mapview to recognize a click, in order to call another activity.
Until now, i tried the regular "onClick",that always worked for me in regular Views, followed by overriding "onTouchEvent" and last but not least using an onClickListener.
I out all three ways into the following code. Any help is highly appreciated.
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
public class HelloMapView extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
final MapView map;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = (MapView) findViewById(R.id.mapview);
map.setOnClickListener(new MapView.OnClickListener() {
public void onClick(View v){
System.out.println("I listened!");
}
});
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
public boolean onTouchEvent(MotionEvent arg0) {
System.out.println("onTouchEvent happened!");
super.onTouchEvent(arg0);
return super.onTouchEvent(arg0);
}
public void onClick(){
System.out.println("onClick entered!");
}
}