Reputation: 6838
I'm doing some work with OSM maps and its MapView supports an OnItemGestureListener for single and long presses for items placed on the MapView. I'm trying to come up with a way to display a context menu for an item when long pressed (e.g. a list of commands). I can't use the usual Activity onCreateContextMenu approach because I don't have a View to registerForContextMenu() with. If I register the MapView, I'll get the context menu popping up whenever I hold the MapView for a second, even when panning.
So I'm thinking I have to either use the MenuInflater with a ContextMenu or just Menu object that I can call to show when the long press callback is made. However neither Menu object allows for a constructor or other way to hold a Menu object and a way to show and callback.
Should I just create a separate layout with the menu items as Views, then pop it up when the long press is made? Thanks.
Upvotes: 1
Views: 619
Reputation: 4970
How about showing a DialogFragment that simulates the ContextMenu functionality, check out this link: http://android-developers.blogspot.in/2012/05/using-dialogfragments.html
You can pretty much put any functionality on that fragment
Upvotes: 0