polfdz / osmbonuspack

Automatically exported from code.google.com/p/osmbonuspack
0 stars 0 forks source link

Customizing the bubble behaviour: with a ContextMenu? #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
See tutorial 2, step 7: Customizing the bubble behaviour:

On clicking ?? on a bubble, can I start a ContextMenu? E.g. to delete the 
bubble, update it, etc, etc. 

I've tried many solutions, but cannot find a good one. 
Much appreciated is your help. 

Original issue reported on code.google.com by janvdijs...@gmail.com on 4 Jan 2014 at 7:47

GoogleCodeExporter commented 9 years ago
In your CustomInfoWindow constructor, add this:

((Activity) mapView.getContext()).registerForContextMenu(mView);
mView.setOnTouchListener(new View.OnTouchListener() {
    @Override public boolean onTouch(View v, MotionEvent e) {
        if (e.getAction() == MotionEvent.ACTION_UP){
            openContextMenu(mView);
        }
        return true;
    }
});

Then implement onCreateContextMenu in your Activity, inflating your menu. 

Then implement onContextItemSelected in your Activity, inflating your menu, to 
perform the actions you want. 

It should work... 

Original comment by mathieu....@gmail.com on 7 Jan 2014 at 1:02

GoogleCodeExporter commented 9 years ago
Thank you for helping. 

Calling the openContextMenu ... is the CustomInfoWindow put in your example as 
an claas within your activity? 

An example would greatly help. 

Original comment by janvdijs...@gmail.com on 10 Jan 2014 at 8:00

GoogleCodeExporter commented 9 years ago
Effectively, the CustomInfoWindow in my example was an inside class in my 
activity. 

Just write: 
((Activity) mapView.getContext()).openContextMenu(mView);
if it's an independant class. 

Original comment by mathieu....@gmail.com on 11 Jan 2014 at 2:17

GoogleCodeExporter commented 9 years ago

Original comment by mathieu....@gmail.com on 17 Jan 2014 at 5:58

GoogleCodeExporter commented 9 years ago
Thank you. I will experiment with it!

Original comment by janvdijs...@gmail.com on 18 Jan 2014 at 3:59