1

I have a sliding drawer in a map view... Now i need to make this siding drawer dissappear on the click of mapview... I tried mapview.setonclick listener but it didnt worked... How to do it?

coderslay
  • 13,960
  • 31
  • 73
  • 121

2 Answers2

2

here is the similar question was asked here you have to implement with the Overlay class for the map on click event see this

here is the code for implementation

public class MyMapActivity extends MapActivity {

class MapOverlay extends com.google.android.maps.Overlay{       
  @Override
 public boolean onTouchEvent(MotionEvent e, MapView mapView) {   
    if (e.getAction() == 1) {                
        Toast.makeText(getApplicationContext,"on click",2000).show();
    }                            
    return false;
  }        
}

  // MyMapActivity methods
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MapOverlay mapOverlay = new MapOverlay();
    List<Overlay> listOfOverlays = mapView.getOverlays();
    listOfOverlays.clear();
    listOfOverlays.add(mapOverlay);

    }
}
Community
  • 1
  • 1
Pratik
  • 30,639
  • 18
  • 84
  • 159
0

As I mentioned here I would override the onTap method instead of the onTouchEvent if you just want to have an click listener.

Community
  • 1
  • 1
salcosand
  • 2,022
  • 4
  • 24
  • 27